I know how to select rows in a dataframe based on the values of two columns (using code from accepted answer on this question: Conditionally Remove Dataframe Rows with R)
My dataframe looks like this (simplified):
Date Afd Count
2012-03-23 12 0
2012-03-23 16 10
2012-03-23 17 12
2012-03-27 12 3
2012-03-27 16 9
2012-03-27 13 7
2012-03-27 22 5
2012-04-05 12 11
2012-04-05 23 8
Now I use this code:
df <- df[!(df$Afd=="12" & df$Date=="2012-03-23"),]
But I also want to drop another Afd and another Date. Following this logic: if Afd = 12 or 16, and Date = 2012-03-23 or 2012-03-27, then delete row.
Do I have to repeat this line 4 times with the different combinations or is there a better solution? (I suspect the latter)