Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread David Winsemius
On Mar 29, 2010, at 1:53 PM, Thomas Jensen wrote: 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, Portugal) vector_2 <- c(Denmark, Lux

Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread Chuck Cleland
On 3/29/2010 1:53 PM, Thomas Jensen wrote: > 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, > Portugal) > > vector_2 <- c(Denmark

Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread Stephan Kolassa
Hi Thomas, %in% does the trick: vector_1 <- c("Belgium", "Spain", "Greece", "Ireland", "Luxembourg", "Netherlands","Portugal") vector_2 <- c("Denmark", "Luxembourg") vector_1[!(vector_1 %in% vector_2)] HTH, Stephan Thomas Jensen schrieb: Dear R-list, I have a problem which I think is quit

Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread Bert Gunter
?setdiff Bert Gunter Genentech Nonclinical Biostatistics -Original Message- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Thomas Jensen Sent: Monday, March 29, 2010 10:53 AM To: r-help@r-project.org Subject: [R] Finding common an unique

Re: [R] Finding common an unique elements in character vectors

2010-03-29 Thread Henrique Dallazuanna
Try this: setdiff(vector_1, vector_2) On Mon, Mar 29, 2010 at 2:53 PM, Thomas Jensen wrote: > 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, Ne

[R] Finding common an unique elements in character vectors

2010-03-29 Thread Thomas Jensen
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, Portugal) vector_2 <- c(Denmark, Luxembourg) I would like to find the elements in vector_1 that