[R] seeking tip to keep first of multiple observations per ID

John Kane jrkrideau at inbox.com
Fri Mar 15 20:03:38 CET 2013


Probably the first thing to do is supply some sample data 
See https://github.com/hadley/devtools/wiki/Reproducibility for some suggestions.

However you may want to take a look at http://stackoverflow.com/questions/13279582/select-only-the-first-rows-for-each-unique-value-of-a-column-in-r particularly at answer number 3 which uses the data.table package and  which looks like it may do what you want.  

John Kane
Kingston ON Canada


> -----Original Message-----
> From: jsdroyster at bellsouth.net
> Sent: Fri, 15 Mar 2013 12:06:05 -0400
> To: r-help at r-project.org
> Subject: [R] seeking tip to keep first of multiple observations per ID
> 
> Dear R community,
> 
> I am a neophyte and I cannot figure out how to accomplish keeping only
> the
> first record for each ID in a data.frame that has assorted numbers of
> records per ID.
> 
> I studied and found references to packages plyr and sql for R, and I fear
> the documentation for those was over my head and I could not identify
> what
> may be there to reach my goal.
> 
> If someone could point me toward a method I will gladly study
> documentation,
> or if there is an example posted someplace I will follow it.
> 
> THANKS!
> Julie
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> 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.

____________________________________________________________
FREE 3D EARTH SCREENSAVER - Watch the Earth right on your desktop!



More information about the R-help mailing list