R whether all elements of X are present in Y
3 answers
Warning setdiff
: if your input vectors have duplicate elements, setdiff
duplicates will be ignored. This may or may not be what you want to do.
I wrote a package vecsets
and here is the difference in what you get. Please note that I have changed X
to demonstrate the behavior.
library(vecsets)
X <- c('a','b','c','d','d')
Y <- c('b', 'e', 'a','d','c','f', 'c')
setdiff(X,Y)
character(0)
vsetdiff(X,Y)
[1] "d"
+2
source to share