library(sqldf)

k1<-data.frame(ID=LETTERS[1:4],
No=c(rep(123,3),111),
Change=c("final","error","bug fixed","final"),
Date=c("2013-01-15","2013-01-16","2013-01-17","2013-01-12"))
 
k1$Date=as.Date(as.character(k1$Date),tz=UK)
 
sqldf("select *
from k1
group by No
having max(Date)")


--- On Fri, 1/2/13, Mat <matthias.weber@fnt.de> wrote:


From: Mat <matthias.weber@fnt.de>
Subject: [R] Filter according to the latest data
To: r-help@r-project.org
Date: Friday, 1 February, 2013, 1:34 PM


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@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.

	[[alternative HTML version deleted]]

