This was actually the one I was looking for, thx. It's actually essentially
a wrapper for %in%, can't imagine I missed that one. I tried it out but I
put the vectors in the wrong order (giving a vector of length 3). Guess it's
too late to think clearly.

Cheers

On Sat, Apr 3, 2010 at 12:55 AM, <mohamed.lajnef@inserm.fr> wrote:

> Hi Joris
>
> Try Is.element function: is.element (x,y)
>
> Regards
> mohamed
>
> Joris Meys <jorismeys@gmail.com> a écrit :
>
>  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.Meys@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.
>>
>>
>
>
> ----------------------------------------------------------------
> This message was sent using IMP, the Internet Messaging Program.
>
>
>


-- 
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.Meys@Ugent.be
-------------------------------
Disclaimer : http://helpdesk.ugent.be/e-maildisclaimer.php

	[[alternative HTML version deleted]]

