Hi,

Imagine a vector x with elements (1,2,1,1,3,5,3,3,1) and a vector y with
elements (2,3). I need to find out what elements of x match any of the
elements of y.

Is there a simple command that will return a vector with elements
(F,T,F,F,T,F,T,T,F). Ideally, I would like a solution that works with
dataframe colums as well.

I have tried x==y and it doesn't work.
x==any(y) doesn't work either. I realize I could write a foor loop and go
through each element of y asking if it matches any element of x, but isn't
there a shorter way?

Thanks,
Gonçalo

        [[alternative HTML version deleted]]

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to