I have 2 data frame d1
and d2
. Both of them has a column called value
.
I want to separate d2 to two data frame: d3 and d4. d3 should contains the rows with value
does not appear in d1
, and d4
contains the rows from d2
with value
appear in d1
.
I tried:
d3 = d2[!is.element(d2$value, d1$value),]
But it seems not correct: the items of d3
is not as expected.
Thanks in advance for your help.
Update:
It seems that anti_join
is not the solution
The sample data:
d1 = as.data.frame(c(1,2,3,4,5,6,7,8))
colnames(d1) = "value"
d2 = as.data.frame(c(7,8,9,10,11,12))
colnames(d1) = "value"
So, d3
should contain 9,10,11,12
(because 9,10,11,12 do not appear in d1) and d4
should contain 7,8
(because 7,8 appear in d1)