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

Philipp Pagel p.pagel at wzw.tum.de
Sat May 31 23:27:09 CEST 2008


> 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
intersect(x,z)

cu
	Philipp

-- 
Dr. Philipp Pagel
Lehrstuhl für Genomorientierte Bioinformatik
Technische Universität München
Wissenschaftszentrum Weihenstephan
85350 Freising, Germany
 
 and
 
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
http://mips.gsf.de/staff/pagel



More information about the R-help mailing list