[datatable-help] subsetting .SD

Matthew Finkbeiner matthew.finkbeiner at gmail.com
Sat Feb 25 06:06:55 CET 2012


I know that we shouldn't subset .SD, but I would like to return the row
from each group that corresponds to a max value in one of the columns.
 Here's how I'm doing it currently:

maxrows<- df.dt[, .SD[which(X1== max(X1)),], by = list(Var1, Var2, Var3)]

Is there a better way?

Thank you kindly,

Matthew
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120225/5aa344dd/attachment-0001.html>


More information about the datatable-help mailing list