I have a big dataframe and I want to remove all rows if the number of rows for a given group based on a column in this datafram is less than a given number. Here is an example:
x=1:6; y=c("A","B","B","B","C","C")
df<- data.frame(x,y)
If I group by variable y, I have three rows that belong to group "B". Here I want to remove all rows that don't satisfy this condition (<3 rows). Expected output:
df
x y
1 2 B
2 3 B
3 4 B
Is there an easy way to do this?