I have two data frames(df and df1). df1 is subset of df. I want to get a data frame which is complement of df1 in df, i.e. return rows of the first data set which are not ma
Another option, using base R and the setdiff function:
df2 <- data.frame(heads = setdiff(df$heads, df1$heads))
setdiff functions exactly as you would imagine; take both arguments as sets, and remove all items in the second from the first.
I find setdiff more readable tahtn %in% and prefer not to require additional libraries when I don't need them, but which answer you use is largely a question of personal taste.