[datatable-help] subsetting .SD
Matthew Finkbeiner
matthew.finkbeiner at gmail.com
Sat Feb 25 11:22:36 CET 2012
Thanks, that is much faster. I don't quite understand it, but that's OK
for now.
Thanks again,
Matthew
On Sat, Feb 25, 2012 at 9:00 PM, Matthew Dowle <mdowle at mdowle.plus.com>wrote:
> Hi. There have been thoughts of adding .I for that. In the meantime
> something like this should be faster:
> DT[DT[,X1==max(X1),by='x,y,z'][[4]]]
>
> > 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
> > _______________________________________________
> > 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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20120225/ee6bb38b/attachment.html>
More information about the datatable-help
mailing list