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
Late answer, but for another option we can try doing a formal SQL anti join, using the sqldf
package:
library(sqldf)
sql <- "SELECT t1.heads
FROM df t1 LEFT JOIN df1 t2
ON t1.heads = t2.heads
WHERE t2.heads IS NULL"
df2 <- sqldf(sql)
The sqldf
package can be useful for those problems which are easily phrased using SQL logic, but perhaps less easily phrased using base R or another R package.