[R] A kind of set operation in R
Julio Sergio
juliosergio at gmail.com
Thu Apr 5 21:32:20 CEST 2012
I have an ordered "set" of numbers, represented by a vector, say
> X <- c(10:13, 17,18)
> X
[1] 10 11 12 13 17 18
then I have a "sub-set" of X, say
> Y <- c(11,12,17,18)
Is there a simple way in R to have a logical vector (parallel to X) indicating
what elements of X are in Y, i.e.,
> Inclusion
[1] FALSE TRUE TRUE FALSE TRUE TRUE
I'm trying to avoid looping over both vectors to produce the tests. Do you have
any comments on this?
Thanks,
--Sergio.
More information about the R-help
mailing list