Equivalent of 'first.var' or 'last.var' from SAS in R?
On Thu, Sep 25, 2008 at 2:00 PM, Matthew Pettis
<matthew.pettis at gmail.com> 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