我有一个数据帧,其中,我想每个组内删除第一和最后观测。我测试了以下和它做什么,我希望:
df <- data.frame(v1 = c(1,1,1,1,1,2,2,2,2,2,3,3,3,3,3),
v2 = c(1,2,3,4,5,1,2,3,4,5,1,2,3,4,5))
df %>%
group_by(v1) %>%
slice(-c(1,n())
# A tibble: 9 x 2
# Groups: v1 [3]
v1 v2
<dbl> <dbl>
1 1 2
2 1 3
3 1 4
4 2 2
5 2 3
6 2 4
7 3 2
8 3 3
9 3 4
但是当我用实际的df运行它时,它将删除所有观察结果。我该如何解决?
下面是我的实际数据以及数据框的子集的代码。
df.detTot2 <- df.detTot %>%
ungroup() %>% #added in incase there was additional grouping from previous
group_by(ID, recvDeployName2, doy.local, ts.h.local) %>%
slice(-c(1, n()))
dim(df.detTot2)
[1] 0 8
dput(df.detTot[1:100,])
structure(list(ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L), .Label = c("NB2014.12",
"NB2014.13", "NB2014.14", "NB2014.15", "NB2014.16", "NB2014.42",
"NB2014.43", "NB2014.44", "NB2014.45", "NB2014.47", "NB2014.48",
"NB2014.49", "NB2014.70", "NB2014.71", "NB2014.72", "NB2014.73",
"NB2014.74", "NB2014.75", "NB2014.76", "NB2014.77", "NB2014.78",
"NB2014.79", "NB2014.80", "NB2014.81", "NB2015.156", "NB2015.157",
"NB2015.158", "NB2015.159", "NB2015.160", "NB2015.312", "NB2015.313",
"NB2015.314", "NB2015.315", "NB2015.316", "NB2015.317", "NB2015.318",
"NB2015.320", "NB2015.321", "NB2015.322", "NB2015.323", "NB2015.324",
"NB2015.325", "NB2015.326", "NB2015.327", "NB2015.328", "NB2015.329",
"NB2015.330", "NB2015.331", "NB2015.332", "NB2015.333", "NB2015.334",
"NB2015.335", "NB2015.336", "NB2015.337", "NB2015.338", "NB2015.339",
"NB2015.340", "NB2015.341", "NB2015.342", "NB2015.343", "NB2015.344",
"NB2015.345", "NB2015.346", "NB2015.347", "NB2015.348", "NB2015.349",
"NB2015.350", "NB2015.351", "NB2018.10", "NB2018.11", "NB2018.12",
"NB2018.13", "NB2018.14", "NB2018.15", "NB2018.16", "NB2018.17",
"NB2018.18", "NB2018.19", "NB2018.20", "NB2018.21", "NB2018.22",
"NB2018.23", "NB2018.24", "NB2018.25", "NB2018.26", "NB2018.27",
"NB2018.28", "NB2018.29", "NB2018.30", "NB2018.31", "NB2018.32",
"NB2018.33", "NB2018.34", "NB2018.35", "NB2018.37", "NB2018.38",
"NB2018.39", "NB2018.40", "NB2018.41", "NB2018.42", "NB2018.43",
"NB2018.44", "NB2018.45", "NB2018.46", "NB2018.47", "NB2018.48",
"NB2018.49", "NB2018.5", "NB2018.50", "NB2018.51", "NB2018.52",
"NB2018.53", "NB2018.54", "NB2018.55", "NB2018.56", "NB2018.57",
"NB2018.58", "NB2018.59", "NB2018.6", "NB2018.60", "NB2018.61",
"NB2018.62", "NB2018.63", "NB2018.64", "NB2018.7", "NB2018.8",
"NB2018.9"), class = "factor"), speciesEN = c("Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow"), recvDeployName2 = c("Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar"), year = c(2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014
), ts.h.local = c(5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 5L, 6L, 7L,
8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L,
21L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L,
16L, 17L, 18L, 19L, 20L, 21L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L), doy.local = c(183, 183,
183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
183, 183, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 185, 185, 185, 185, 185, 185, 185,
185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 186, 186, 186,
186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 188, 188, 188, 188, 188, 188, 188, 188, 188,
188, 188, 188, 188, 188, 188, 188), nDet = c(0, 0, 0, 0, 10,
23, 7, 41, 0, 0, 28, 3, 35, 39, 29, 40, 0, 0, 0, 13, 35, 43,
106, 136, 116, 77, 43, 149, 130, 60, 44, 169, 26, 2, 6, 48, 38,
38, 127, 50, 28, 74, 162, 211, 138, 85, 63, 63, 67, 30, 2, 0,
0, 71, 2, 53, 161, 143, 63, 107, 26, 0, 0, 260, 168, 54, 46,
132, 291, 171, 204, 154, 75, 198, 80, 155, 205, 158, 203, 137,
59, 47, 170, 36, 95, 131, 167, 124, 100, 130, 131, 247, 247,
102, 177, 191, 93, 171, 180, 127), dayNight = c("day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day", "day",
"day", "day", "day", "day", "day", "day", "day", "day")), row.names = c(NA,
-100L), class = c("grouped_df", "tbl_df", "tbl", "data.frame"
), vars = c("ID", "speciesEN", "recvDeployName2", "year", "doy.local",
"ts.h.local"), drop = TRUE, indices = list(0L, 1L, 2L, 3L, 4L,
5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L,
18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 29L,
30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L,
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L,
54L, 55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L,
66L, 67L, 68L, 69L, 70L, 71L, 72L, 73L, 74L, 75L, 76L, 77L,
78L, 79L, 80L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 88L, 89L,
90L, 91L, 92L, 93L, 94L, 95L, 96L, 97L, 98L, 99L), group_sizes = c(1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L), biggest_group_size = 1L, labels = structure(list(
ID = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L
), .Label = c("NB2014.12", "NB2014.13", "NB2014.14", "NB2014.15",
"NB2014.16", "NB2014.42", "NB2014.43", "NB2014.44", "NB2014.45",
"NB2014.47", "NB2014.48", "NB2014.49", "NB2014.70", "NB2014.71",
"NB2014.72", "NB2014.73", "NB2014.74", "NB2014.75", "NB2014.76",
"NB2014.77", "NB2014.78", "NB2014.79", "NB2014.80", "NB2014.81",
"NB2015.156", "NB2015.157", "NB2015.158", "NB2015.159", "NB2015.160",
"NB2015.312", "NB2015.313", "NB2015.314", "NB2015.315", "NB2015.316",
"NB2015.317", "NB2015.318", "NB2015.320", "NB2015.321", "NB2015.322",
"NB2015.323", "NB2015.324", "NB2015.325", "NB2015.326", "NB2015.327",
"NB2015.328", "NB2015.329", "NB2015.330", "NB2015.331", "NB2015.332",
"NB2015.333", "NB2015.334", "NB2015.335", "NB2015.336", "NB2015.337",
"NB2015.338", "NB2015.339", "NB2015.340", "NB2015.341", "NB2015.342",
"NB2015.343", "NB2015.344", "NB2015.345", "NB2015.346", "NB2015.347",
"NB2015.348", "NB2015.349", "NB2015.350", "NB2015.351", "NB2018.10",
"NB2018.11", "NB2018.12", "NB2018.13", "NB2018.14", "NB2018.15",
"NB2018.16", "NB2018.17", "NB2018.18", "NB2018.19", "NB2018.20",
"NB2018.21", "NB2018.22", "NB2018.23", "NB2018.24", "NB2018.25",
"NB2018.26", "NB2018.27", "NB2018.28", "NB2018.29", "NB2018.30",
"NB2018.31", "NB2018.32", "NB2018.33", "NB2018.34", "NB2018.35",
"NB2018.37", "NB2018.38", "NB2018.39", "NB2018.40", "NB2018.41",
"NB2018.42", "NB2018.43", "NB2018.44", "NB2018.45", "NB2018.46",
"NB2018.47", "NB2018.48", "NB2018.49", "NB2018.5", "NB2018.50",
"NB2018.51", "NB2018.52", "NB2018.53", "NB2018.54", "NB2018.55",
"NB2018.56", "NB2018.57", "NB2018.58", "NB2018.59", "NB2018.6",
"NB2018.60", "NB2018.61", "NB2018.62", "NB2018.63", "NB2018.64",
"NB2018.7", "NB2018.8", "NB2018.9"), class = "factor"), speciesEN = c("Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow", "Bank Swallow",
"Bank Swallow", "Bank Swallow", "Bank Swallow"), recvDeployName2 = c("Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar", "Tantramar",
"Tantramar", "Tantramar", "Tantramar", "Tantramar"), year = c(2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014,
2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014, 2014), doy.local = c(183,
183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183, 183,
183, 183, 183, 183, 184, 184, 184, 184, 184, 184, 184, 184,
184, 184, 184, 184, 184, 184, 184, 184, 184, 185, 185, 185,
185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185, 185,
185, 185, 186, 186, 186, 186, 186, 186, 186, 186, 186, 186,
186, 186, 186, 186, 186, 186, 187, 187, 187, 187, 187, 187,
187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 187, 188,
188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188,
188, 188, 188), ts.h.local = c(5L, 6L, 7L, 8L, 9L, 10L, 11L,
12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 21L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L, 21L, 5L, 6L, 7L, 8L, 9L, 10L,
11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L, 19L, 20L, 5L, 6L,
7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L,
15L, 16L, 17L, 18L, 19L, 20L)), row.names = c(NA, -100L), class = "data.frame", vars = c("ID",
"speciesEN", "recvDeployName2", "year", "doy.local", "ts.h.local"
), drop = TRUE))
答案 0 :(得分:2)
您不应group_by
ts.h.local
df %>%
ungroup() %>%
group_by(ID, recvDeployName2, doy.local) %>%
slice(-c(1, n()))