Dear all,

I have a vector, and for each element I want to check whether it is equal to
any element from another vector. I want a vector of logical values with the
length of the first one as return. In R this would be :

> x <- 1:10
> sapply(x,function(y){any(y==c("2","3","4"))})
[1] FALSE  TRUE  TRUE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE

It works pretty smooth, but I have the feeling there's a less complicated
way of doing it. My code should be readable by programmers who are not
really familiar with R, but I hate to use for-loops as I have pretty huge
datasets. Anybody an idea?
thank you in advance.

Cheers
Joris

-- 
Joris Meys
Statistical Consultant

Ghent University
Faculty of Bioscience Engineering
Department of Applied mathematics, biometrics and process control

Coupure Links 653
B-9000 Gent

tel : +32 9 264 59 87
joris.m...@ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org 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