Simple question, but didn't find it on stackoverflow. Is there a function for finding all non-identical values:
x <- c("a","b","c","d")
y <- c("a","f","g","c","d")
result should be:
res <- c("b","f","g")
All functions seem to only work for one vector. setdiff()
etc.
This popped up on Tony Breyal's blog a few years ago, you can see several solutions there, here's the shortest one:
c(setdiff(x,y),setdiff(y,x))
setdiff(union(x, y), intersect(x, y))
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