[datatable-help] Subsetting By Row Function

PARIS Nicolas niparisco at gmail.com
Sun Jul 20 13:58:27 CEST 2014


Hello Ben,

What about ordering on group+date descending, then removing duplicated
on group ?

someting like :
DT[!duplicated(Group),][order(Group,asDate(Date,format="yourFormat"),decreasing=T)]


Le 19/07/2014 00:40, bgoldstein a écrit :
> I am having trouble defining (and therefore searching) for this problem. I
> have data like this:
> 
> Group Value Date
> 1         xxx   June
> 1         yyy   July
> 2         zzzz   May
> 2         qqqq  August
> etc.
> 
> 
> I want to subset the 'Value' of each 'Group' by the latest 'Date'. So my
> output should be:
> 
> Group Value Date
> 1         yyy   July
> 2         qqqq  August
> etc.
> 
> The doBy package has a firstobs() function that works but is quite slow.
> 
> What would be a data.table way to do this?
> 
> Thank you,
> 
> Ben
> 
> 
> 
> --
> View this message in context: http://r.789695.n4.nabble.com/Subsetting-By-Row-Function-tp4694221.html
> Sent from the datatable-help mailing list archive at Nabble.com.
> _______________________________________________
> datatable-help mailing list
> datatable-help at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help
> 



More information about the datatable-help mailing list