[R] extracting selected rows, based on a 'list' of values
Liaw, Andy
andy_liaw at merck.com
Sat Apr 23 20:53:33 CEST 2005
[No need to post the same message twice, please.]
Try something like:
dat <- data.frame(a=sample(c("a", "b", "d", "k", "z"), 30, replace=TRUE),
b=runif(30))
subset(dat, a %in% c("a", "d", "k", "z"))
Andy
> From: Tim Smith
>
> Hi,
>
> I was trying to extract certain rows from a table. For
> example, if the value in the first column is "a", "d", "k",
> or "z", then I would like to extract these rows. In other
> words, if the value in the column is also an element in my
> list (a,d,k,z), then I would like to extract the row.
>
> I've looked in the archives and the solutions I could find
> were restriced to the value in the row name being a single element.
>
> thanks for the help,
>
> Tim
More information about the R-help
mailing list