Re: [R] Keep rows where a variable matches one item of a vector

2012-01-12 Thread Sarah Goslee
Hi, On Thu, Jan 12, 2012 at 3:10 PM, dadrivr wrote: > How do I subset data to only keep those rows of a dataframe where a > variable's value matches one item of a vector.  For example, how do I keep > all of the rows (and all variables) where mydata$id equals one of the values > in keepid?  See b

[R] Keep rows where a variable matches one item of a vector

2012-01-12 Thread dadrivr
How do I subset data to only keep those rows of a dataframe where a variable's value matches one item of a vector. For example, how do I keep all of the rows (and all variables) where mydata$id equals one of the values in keepid? See below? mydata <- NULL mydata$id <- 1:30 mydata$value <- seq(fr