Re: [R] Matching two vectors

2011-03-15 Thread nblarson
Just use vect_2_id as a subsetting index for vect_1, ie: vect_2<-vect_1[vect_2_id] Vincy Pyne wrote: > > Dear R helpers > > Suppose I have a vector as > > vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") > > vect_1_id = c(1:length(vect_1)) > > Through some process I obtain > > vect_2_

Re: [R] Matching two vectors

2011-03-15 Thread Sarah Goslee
vect_1[vect_2_id] and perhaps a readthrough of some of the very nice intro to R materials available online. Sarah On Tue, Mar 15, 2011 at 3:41 PM, Vincy Pyne wrote: > Dear R helpers > > Suppose I have a vector as > > vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") > > vect_1_id = c(1:leng

[R] Matching two vectors

2011-03-15 Thread Vincy Pyne
Dear R helpers Suppose I have a vector as vect_1 = c("AAA", "AA", "A", "BBB", "BB", "B", "CCC") vect_1_id = c(1:length(vect_1)) Through some process I obtain vect_2_id = c(2, 3, 7), then I need a new vector say vect_2 which will give me vect2 = ("AA", "A", "CCC")  i.e. I need the subset of ve