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.
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. >
p_connolly at slingshot.co.nz
2013-Jan-17 23:13 UTC
[R] How can i keep only latest entries?
Quoting Mat <matthias.weber at fnt.de>:> 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 >Calling your data frame, x and assuming the `last change` column is character, x[x$`last change` == "final",] will give what you want. If `last change` is a factor column (likely), x[as.character(x$`last change`) == "final",] If you don't have spaces in your column names, you'd avoid using the backticks. HTH> 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.