I have a data frame. I want to filter out some problems only if they are related to a specific group.
For a dummy example, suppose I have the following:
> mydf
Group Issue
1 A G
2 A H
3 A L
4 B V
5 B M
6 C G
7 C H
8 C L
9 C X
10 D G
11 D H
12 D I
I want to filter out lines with an error of "G" or "H" or "L" if there is also an "L" problem in this group.
So, in this case, I want to filter lines 1, 2, 3, 6,7,8, but leave lines 4,5,9, 10, 11 and 12. Thus, the result will be:
> mydf
Group Issue
4 B V
5 B M
9 C X
10 D G
11 D H
12 D I
It seems to me that I need first group_by(Group), but then I wonder what is the best way to do this.
Thank!
source
share