I have a dataframe with groups of Sequ
ences:
df <- data.frame(
ID = letters[1:13],
Sequ = c(NA,1,1,1,2,3,3,3,NA,NA,4,4,4,4)
)
I want to filter groups that have more than a critical number n of members; let's suppose that critical number n is 3. This attempt only selects the 4th member row but not the Sequ
ence as a whole:
df %>%
group_by(Sequ) %>%
filter(row_number() > 3)
# A tibble: 1 × 2
# Groups: Sequ [1]
ID Sequ
<chr> <dbl>
1 n 4
So how can I get this desired output, ideally with 'dplyr` but other solutions are welcome as well:
df
ID Sequ
1 k 4
2 l 4
3 m 4
4 n 4