[R] by-group processing
hadley wickham
h.wickham at gmail.com
Sat May 9 03:11:46 CEST 2009
On Wed, May 6, 2009 at 8:12 PM, jim holtman <jholtman at gmail.com> wrote:
> Ths should do it:
>
>> do.call(rbind, lapply(split(x, x$ID), tail, 1))
> ID Type N
> 45900 45900 I 7
> 46550 46550 I 7
> 49270 49270 E 3
Or with plyr:
library(plyr)
ddply(x, "id", tail, 1)
plyr encapsulates the common split-apply-combine strategy and takes
cares of the details for you. Read more about it on
http://had.co.nz/plyr
Hadley
--
http://had.co.nz/
More information about the R-help
mailing list