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

From: Philipp Pagel <>
Date: Sat, 31 May 2008 23:27:09 +0200

> 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.

In addition to the solution using %in% which has already been suggested, you may also want to play with something like this:

# make up some data
x = sample(1:8, 10, rep=T)
z = sample(1:25, 75, rep=T)
# find intersection between x and z



Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
Institut für Bioinformatik und Systembiologie / MIPS
Helmholtz Zentrum München -
Deutsches Forschungszentrum für Gesundheit und Umwelt
Ingolstädter Landstrasse 1
85764 Neuherberg, Germany

______________________________________________ mailing list
PLEASE do read the posting guide
and provide commented, minimal, self-contained, reproducible code.
Received on Mon 02 Jun 2008 - 04:13: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 - 18:30:40 GMT.

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

list of date sections of archive