我有一个data.frame:
d <- structure(list(ID = c(1L, 1L, 2L, 2L, 2L, 2L, 3L, 3L, 3L, 4L,
4L, 4L, 4L, 5L, 5L, 6L, 6L, 6L, 6L, 6L, 6L, 7L, 7L, 8L, 8L, 8L,
9L, 9L, 10L, 10L, 10L, 10L, 11L, 11L, 12L, 12L, 13L, 13L, 14L,
14L, 14L, 14L, 14L, 14L, 15L, 15L, 15L, 15L, 15L, 16L, 16L, 17L,
17L, 18L, 18L, 19L