I try to filter the group that contains min x value in them. But I would like to keep the entire group.
Similar post in here but not for min value
filtering
Remove groups that contain certain strings
So I try
df <-data.frame(x=c(250,240,233,250,100,10,250,100,1),gr=gl(3,3))
> df
x gr
1 250 1
2 240 1
3 233 1
4 250 2
5 100 2
6 10 2
7 250 3
8 100 3
9 1 3
df%>%
group_by(gr)%>%
filter(all(x==min(x)))
Returning the empty df. Why ?
the expected output would be
x gr
7 250 3
8 100 3
9 1 3