Hi,
Perhaps, (#Untested)
do.call(rbind,lapply(split(dat1,dat1$No),function(x) tail(x,1)))
#or
library(plyr)
ddply(dat1,.(No), function(x) x[nrow(x),])
A.K.
----- Original Message -----
From: Mat <matthias.weber at fnt.de>
To: r-help at r-project.org
Cc:
Sent: Friday, February 1, 2013 3:04 AM
Subject: [R] Filter according to the latest data
Hello together,
i have a data.frame, like this one:
? ? ? ? ? ? ? ? No.? ? ? ? ? Change? ? ? ? ? Date? ? ? ? ?
A? ? ? ? ? ? ? 123? ? ? ? ? final? ? ? ? ? ? ? ? 2013-01-15
B? ? ? ? ? ? ? 123? ? ? ? ? error? ? ? ? ? ? ? 2013-01-16
C? ? ? ? ? ? ? 123? ? ? ? ? bug fixed? ? ? 2013-01-17
D? ? ? ? ? ? ? 111? ? ? ? ? final? ? ? ? ? ? ? ? 2013-01-12
and now a want a new data.frame which includes only the newest entry for
each number.
The solution look like this:
? ? ? ? ? ? ? ? No.? ? ? ? ? Change? ? ? ? ? Date? ? ? ? ?
C? ? ? ? ? ? ? 123? ? ? ? ? bug fixed? ? ? 2013-01-17
D? ? ? ? ? ? ? 111? ? ? ? ? final? ? ? ? ? ? ? ? 2013-01-12
is there any way to filter my data.frame to the latest data, perhabs "max"?
Thanks.
Mat
--
View this message in context: http://r.789695.n4.nabble.com/Filter-according-to-the-latest-data-tp4657248.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
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.