<font face="arial, helvetica, sans-serif">as.data.table(lapply(DT, sum)) works and doesn&#39;t seem much less elegant?</font><div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">(Well -- it would work if you were not trying to take the sum of a factor ;-))</font></div>

<div><font face="arial, helvetica, sans-serif"><br></font></div><div><font face="arial, helvetica, sans-serif">t</font><br><div><br><div class="gmail_quote">On Mon, Jan 9, 2012 at 4:45 PM, Joseph Voelkel <span dir="ltr">&lt;<a href="mailto:jgvcqa@rit.edu">jgvcqa@rit.edu</a>&gt;</span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div lang="EN-US" link="blue" vlink="purple"><div><p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"># from  help(data.table)<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">DT = data.table(x=rep(c(&quot;a&quot;,&quot;b&quot;,&quot;c&quot;),each=3), y=c(1,3,6), v=1:9)<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">DT[,lapply(.SD,sum),by=x]  # this works fine<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"><u></u> <u></u></span></p>

<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"># but this fails<u></u><u></u></span></p><p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222">DT[,lapply(.SD,sum)]<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"># with this message: Error in lapply(.SD, sum) : object &#39;.SD&#39; not found<u></u><u></u></span></p>

<p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"><u></u> <u></u></span></p><p class="MsoNormal"><span style="font-size:7.5pt;font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;color:#222222"># Am I missing something obvious here?<u></u><u></u></span></p>

<p class="MsoNormal"><u></u> <u></u></p></div></div><br>_______________________________________________<br>
datatable-help mailing list<br>
<a href="mailto:datatable-help@lists.r-forge.r-project.org">datatable-help@lists.r-forge.r-project.org</a><br>
<a href="https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help" target="_blank">https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/datatable-help</a><br></blockquote></div><br></div></div>