I have a df1 like this:
text 1
text 2
text 3
text 4
text 5
And another one df2 like this:
text 1
text 2
text 3
text 5
The problem is my dfs are almost the same, they have many rows and I can find the one that is additional to the first df in order to know who is it?
Is there any possible option to compare the two dfs and find the one row it is the difference between them?
You can rbind
the two and then find the non-duplicated rows.
For example, if you have data frames a
and b
then
x <- rbind(a, b)
x[!duplicated(x) & !duplicated(x, fromLast = TRUE), ]
# V1 V2
# 4 text 4
Or if you prefer, you can use dplyr::setdiff()
, which has a data frame method.
dplyr::setdiff(a, b)
# V1 V2
# 1 text 4
where
a <- read.table(text = "text 1
text 2
text 3
text 4
text 5", header = FALSE)
b <- a[-4, ]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With