R. Do all x elements exist in Y
•
Java
In R, how to test the elements of a vector that does not exist in another vector?
X <- c('a','b','c','d') Y <- c('b','e','a','d','f','c')
I wonder if all the elements of X exist in Y? (true or false answer)
Solution
You want setdiff:
> setdiff(X,Y) # all elements present in X but not Y character(0) > length(setdiff(X,Y)) == 0 [1] TRUE
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码