[datatable-help] Slow execution: Extracting last value in each group

Frank Erickson FErickson at psu.edu
Fri Aug 16 12:34:44 CEST 2013


I get similar timings to arun, with the data.table call being a lot slower
than the other timings. If data.table is not optimized for that .SD
expression, perhaps that is okay because, as Arun pointed out, there are
alternatives.. I can't guess why it would perform differently on different
hardware, though...

# alternatives:
a <- dt1[dt1[, .I[.N], by='Date']$V1]
b <- dt1[J(unique(Date)),,mult='last'] # a little slower
d <- dt1[, .SD[.N], by='Date'] # 600x slower; it would take ages to
benchmark
identical(a,b) # true
identical(a,d) # false
identical(as.data.frame(d),as.data.frame(a)) # true

--Frank
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20130816/e80acbd3/attachment.html>


More information about the datatable-help mailing list