我有一系列的状态和相应的月份。
mcdata <- structure(list(state = structure(c(2L, 1L, 2L, 2L, 2L, 2L, 4L,
4L, 2L, 4L, 2L, 3L, 1L, 3L, 2L, 2L, 2L, 4L, 2L, 3L, 4L, 2L, 3L,
3L, 3L, 3L, 3L, 1L, 4L, 2L, 3L, 2L, 2L, 4L, 3L, 2L, 4L, 3L, 2L,
2L, 3L), .Label = c("1", "2", "3", "4"), clas