Hello I have a df such as :
Groups COL2 COL3
G1 2 8
G1 3 4
G1 0 3
G2 1 3
G2 9 4
G3 3 89
G3 3 5
G4 1 7
G4 2 3
and I would like to select only groups if at least a row satisfies the two following conditions: COL2 < 3 and COL3 > 5. Thus here I would select only groups G1 and G4.
Groups COL2 COL3
G1 2 8
G1 3 4
G1 0 3
G4 1 7
G4 2 3
I tried:
df%>%
group_by(Groups) %>%
filter(any(COL2 <3) & any(COL3 >5)) %>%