[R] Matching two vectors

From: Vincy Pyne <vincy_pyne_at_yahoo.ca>
Date: Tue, 15 Mar 2011 12:41:47 -0700 (PDT)


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 vect_1 as per vect_2_id.

Thanking in advance

Regards

Vincy

        [[alternative HTML version deleted]]



R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 15 Mar 2011 - 19:51:35 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 Wed 16 Mar 2011 - 01:10:22 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive