[R] subsetting data by specified observation number

Linh Tran Tranlm at berkeley.edu
Sat Mar 5 20:22:30 CET 2011


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 I need to subset from.

linh


> What is wrong with
>
> subset( failed.3, position == 2 )
>
> ?
> --
> Sent from my Android phone with K-9 Mail. Please excuse my brevity.
>
> Linh Tran <Tranlm at berkeley.edu> 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(failed.3) id position 1 10000997 2 4 1000RW_M 2 15 1006RW_G 2 24
> 1012RW_M 3 28 10160917 2 30 1016RW_M 13 I'd like to use this to subset out
> a large dataset and keep only the observation number corresponding to the
> position number. So for example, ID 10000997 has 10 observations. I want
> to keep the 2nd one only. Thanks,
> -linh_____________________________________________
> 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.
>
>


Thanks,

-linh



More information about the R-help mailing list