[R] Extract only certain rows from a table

From: <naw3_at_duke.edu>
Date: Wed, 18 Jun 2008 09:36:45 -0400


I have a table where column 1 has ID numbers and column two has data, and I have a vector containing a subset of those ID numbers. How can I create a new table with only the rows from the old table that match the IDs in the vector, like below:

Original Table:

ID     Value
1        123
2        123
3        123
4        123

vect: [2, 3]

New table:

ID     Value
2        123
3        123

Thank you so much!

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 Wed 18 Jun 2008 - 14:07: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 18 Jun 2008 - 15:30:46 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