Re: [R] Is variable in one vector part of variable in another

From: Dr. S. B. Nguah <>
Date: Sat, 31 May 2008 06:48:17 -0700 (PDT)

darthgervais wrote:
> I have 2 vectors x & z
> x has 10 variables in it
> z has 75 variable in it
> I need to check all 75 variables in z and see if they are present in the
> vector x.
> So far this is what I have:
> for (i in 0:75){
> if (z[i]==x) (w=w+1)
> }
> Thanks in advance
> w

any(!(z%in%x) # if TRUE then extract with z[!(z%in%x)]

Blay S
Kumasi, Ghana.
View this message in context:
Sent from the R help mailing list archive at

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 02 Jun 2008 - 06:39:32 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Mon 02 Jun 2008 - 07:30:38 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.

list of date sections of archive