I have a data frame that contains sample plot information, some of these sample plots have been subdivided by different conditions. My question is how do I remove some of the subdivided rows based on a list of the plots and conditions that need to be removed?
I've tried using this df3 <- df[!(df$PLOT %in% df2$PLOT & df$CONDID %in% df2$CONDID),]
as well as similer variations with the filter() function from the dplyr package. However this just removes all plots/conditions listed in df2.
Here is a simplified version of my data:
df <- data.frame(PLOT = c(82708, 88503, 88503, 88503, 86560, 89773, 82199, 82199, 84113),
CONDID = c(1, 1, 2, 3, 1, 1, 1, 2, 1))
df
And the list I'm trying to use to remove certain plot/conditions looks like this:
df2 <- data.frame(PLOT = c(88503, 88503, 82199), CONDID = c(1, 3, 2))
df2
I want my output data frame to look like this:
df3 <- data.frame(PLOT = c(82708, 88503, 86560, 89773, 82199, 84113), CONDID = c(1, 2, 1, 1, 1, 1))
df3