Message-ID: <de4e29f50911161151x7b24a398p5f404227345f5b6e@mail.gmail.com>
Date: 2009-11-16T19:51:59Z
From: Baptiste Auguie
Subject: extracting the last row of each group in a data frame
In-Reply-To: <6e9bb1ed91068f2ef02f2b705c0fd05f.squirrel@webmail.andrew.cmu.edu>
Hi,
You could try plyr,
library(plyr)
ddply(d,.(Name), tail,1)
Name Value
1 A 3
2 B 8
3 C 2
4 D 3
HTH,
baptiste
2009/11/16 Hao Cen <hcen at andrew.cmu.edu>:
> Hi,
>
> I would like to extract the last row of each group in a data frame.
>
> The data frame is as follows
>
> Name Value
> A 1
> A 2
> A 3
> B 4
> B 8
> C 2
> D 3
>
> I would like to get a data frame as
> Name Value
> A 3
> B 8
> C 2
> D 3
>
> Thank you for your suggestions in advance
>
> Jeff
>
> ______________________________________________
> 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.
>