I have a dataset like this.
ID Group Value Col3
1 z1 1.29 1
1 z1 0.81 1
2 z2 2.89 1
2 z2 1.53 2
3 z1 0.13 3
3 z1 0.97 3
4 z3 10.75 3
4 z3 8.13 2
5 x2 0.45 1
5 x2 1.43 3
How do I retain rows where Col3=2
when duplicates are identified based on group_by(Id,Group)
Expected results
ID Group Value Col3
1 z1 1.29 1
1 z1 0.81 1
2 z2 1.53 2
3 z1 0.13 3
3 z1 0.97 3
4 z3 8.13 2
5 x2 0.45 1
5 x2 1.43 3
Please note that one row in ID 2 and ID 4 are exclude and only rows where Col3=2 is retained. Thanks in advance for any help.
It seems if there is a 2 in a group you want to keep just that, otherwise return all rows. This seems to do the trick
which returns