[datatable-help] .SD without by seems to fail

Timothée Carayol timothee.carayol at gmail.com
Mon Jan 9 19:16:48 CET 2012


as.data.table(lapply(DT, sum)) works and doesn't seem much less elegant?

(Well -- it would work if you were not trying to take the sum of a factor
;-))

t

On Mon, Jan 9, 2012 at 4:45 PM, Joseph Voelkel <jgvcqa at rit.edu> wrote:

> # from  help(data.table)****
>
> DT = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9)****
>
> DT[,lapply(.SD,sum),by=x]  # this works fine****
>
> ** **
>
> # but this fails****
>
> DT[,lapply(.SD,sum)]****
>
> # with this message: Error in lapply(.SD, sum) : object '.SD' not found***
> *
>
> ** **
>
> # Am I missing something obvious here?****
>
> ** **
>
> _______________________________________________
> 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/20120109/64f4af40/attachment.htm>


More information about the datatable-help mailing list