I have two dataframes that look something like this:
dat <- data.frame(col1 = c(1:100))
dat2 <- data.frame(col2 = c(5:105))
I want to find all the elements that are in dat but not in dat2. How can I do this?
Thanks!
>Solution :
You could use a filtering join, e.g.
dplyr::anti_join(dat,dat2, by = c("col1" = "col2"))
or directly via filter
library(dplyr)
dat %>% filter(!col1 %in% dat2$col2)
Output:
col1
1 1
2 2
3 3
4 4