[R] Finding common an unique elements in character vectors

Bert Gunter gunter.berton at gene.com
Mon Mar 29 21:29:27 CEST 2010


Bert Gunter
Genentech Nonclinical Biostatistics

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of Thomas Jensen
Sent: Monday, March 29, 2010 10:53 AM
To: r-help at r-project.org
Subject: [R] Finding common an unique elements in character vectors

Dear R-list,

I have a problem which I think is quite basic, but so far google has not
helped me.

I have two vectors like this:

vector_1 <- c(Belgium, Spain, Greece, Ireland, Luxembourg, Netherlands,

vector_2 <- c(Denmark, Luxembourg)

I would like to find the elements in vector_1 that are not in vector_2

so that i get a vector with these countries: Belgium, Spain, Greece,
Ireland, Netherlands, Portugal.

Thanks a lot,


R-help at r-project.org mailing list
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list