On Thu, Sep 25, 2008 at 2:00 PM, Matthew Pettis <[EMAIL PROTECTED]> wrote: > Hi, > > I want to sort a data frame by multiple columns and then take the > first record in each unique level of the "by" group I used to sort the > data frame. Does someone have an example of how to do this? > > Thanks, > Matt
In the (very soon to be released) plyr package, you can do: library(plyr) ddply(airquality, .(Month), head, 1) ddply(airquality, .(Month), tail, 1) Hadley -- http://had.co.nz/ ______________________________________________ R-help@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.