I have three vectors (a, b, and c) and found the common elements in all three using
common<-Reduce(intersect,list(a,b,c))
I want to find out now which elements are unique to a. I can't use a[!(a%in%common)]
since that could return elements in a and one other vector.
I don't think this is a new or unique question, but part of my problem in finding the answer is that I'm not sure what the a[!(a%in%common)]
function is called.
You can use reduce
and setdiff for an arbitrary length list
Reduce(setdiff, list(a,b,c))
The simple solution would be a[!(a %in% union(b,c))]
.
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