Примените ваши условия в пределах filter
заявления
library(dplyr)
df %>%
group_by(gr) %>%
filter(!(value == 'a' & row_number() == 1))
Пример данных:
df <- structure(list(gr = c(1L, 1L, 1L, 2L, 2L, 3L, 3L, 3L, 3L, 4L,
4L, 4L), value = c("b", "c", "a", "a", "d", "b", "a", "h", "a",
"a", "a", "g")), .Names = c("gr", "value"), class = "data.frame", row.names = c(NA,
-12L))
Обновление: или как @akrun предложил
library(dplyr)
df %>%
group_by(gr) %>%
slice(which(!(value == 'a' & row_number() == 1)))