Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
Here is one way: > tmp1 <- data.frame(Species=c('setosa','virginica','versicolor'), + row=c(7,20,18) ) > > tmp.iris <- iris > tmp.iris$row <- ave(iris$Sepal.Length, iris$Species, FUN=seq_along) > > out.iris <- merge(tmp.iris, tmp1, by=c('Species','row')) > > > out.iris Species row Sepal.L

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Linh Tran
Hi, Thank you for the reply. That would only work for the first ID. In addition, the data frame that I'm trying to subset is separate from the data frame that has the position numbers. "failed.3" is the data frame with the position numbers that I would like to keep. "def3" is the data frame that

Re: [R] subsetting data by specified observation number

2011-03-05 Thread Greg Snow
Will failed.3 have each id exactly once? Or could it have multiple lines for a given id? -- Gregory (Greg) L. Snow Ph.D. Statistical Data Center Intermountain Healthcare greg.s...@imail.org 801.408.8111 > -Original Message- > From: r-help-boun...@r-project.org [mailto:r-help-bounces@r-

Re: [R] subsetting data by specified observation number

2011-03-05 Thread jdnew...@gmail.com
What is wrong with subset( failed.3, position == 2 ) ? -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. Linh Tran wrote: Hi members, I'd like to thank you guys ahead of time for the help. I'm kind of stuck. I have a data frame with ID and position numbers: 1> head(faile