[R] How can i keep only latest entries?

Rui Barradas ruipbarradas at sapo.pt
Thu Jan 17 22:35:23 CET 2013


Hello,

Try the following.
(I've named your data.frame 'dat')

do.call(rbind, lapply(split(dat, dat$`No.`), tail, 1))


Hope this helps,

Rui Barradas

Em 17-01-2013 10:50, Mat escreveu:
> Hello togehter,
>
> i have a data.frame like this one:
>
>      No. Date                 last change
> 1  1     2012-10-04     change settings
> 2  1     2012-10-20     bug fix
> 3  1     2012-11-05     final
> 4  2     2013-01-15    new task
> 5  2     2013-01-16    Bug fix
> 6  2     2013-01-17    final
>
> now i want a new data.frame, who show me only the newest entries according
> to the No.
> The solution look like this one:
>
>     No. Date                last change
> 1  1     2012-11-05   final
> 2  2     2013-01-17   final
>
> can anyone help me?
>
> thanks.
>
> Mat
>
>
>
> --
> View this message in context: http://r.789695.n4.nabble.com/How-can-i-keep-only-latest-entries-tp4655827.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.
>



More information about the R-help mailing list