[datatable-help] Unintuitive behavior with by=
Muhammad Waliji
mhwaliji at google.com
Sat Nov 12 21:08:04 CET 2011
I sometimes want to check the number of rows for each value of a variable.
I use the following method. The first syntax doesn't work, but the second
does. I think that they ought to give the same result.
> DT <- data.table(x=rep(c(1, 2), each=10), y=1:20)
> DT[, length(x), list(x)]
x V1
[1,] 1 1
[2,] 2 1
> DT[, length(y), list(x)]
x V1
[1,] 1 10
[2,] 2 10
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/datatable-help/attachments/20111112/6681d94a/attachment.htm>
More information about the datatable-help
mailing list