I have a data frame with 3 columns
a b c
P1 z 1 22
P2 z 2 18
P3 x 1 3
P4 z 1 16
P5 x 2 6
P6 z 1 12
P7 x 1 23
I want to create a new data frame with only the values in column "c" which meet the condition that there is a "z" in column "a" and a "1" in column "b" + "x" in column "a" and a "2" in column "b".
Afterwards the new data frame should look like this:
a b c
P1 z 1 22
P4 z 1 16
P5 x 2 6
P6 z 1 12
The first thing that comes in mind is to use subset(). But I don't know how. Thank you for your help.