title: Summarizing multiple columns with data.table
body: <p>I'm trying to use data.table to speed up processing of a large data.frame (300k x 60) made of several smaller merged data.frames. I'm new to data.table. The code so far is as follows</p>
  
  <pre><code>library(data.table)
  a = data.table(index=1:5,a=rnorm(5,10),b=rnorm(5,10),z=rnorm(5,10))
  b = data.table(index=6:10,a=rnorm(5,10),b=rnorm(5,10),c=rnorm(5,10),d=rnorm(5,10))
  dt = merge(a,b,by=intersect(names(a),names(b)),all=T)
  dt$category = sample(letters[1:3],10,replace=T)
  </code></pre>
  
  <p>and I wondered if there was a more efficient way than the following to summarize the data.</p>
  
  <pre><code>summ = dt[i=T,j=list(a=sum(a,na.rm=T),b=sum(b,na.rm=T),c=sum(c,na.rm=T),
                       d=sum(d,na.rm=T),z=sum(z,na.rm=T)),by=category]
  </code></pre>
  
  <p>I don't really want to type all 50 column calculations by hand and a <code>eval(paste(...))</code> seems clunky somehow.</p>
  
  <p>I had a look at the example below but it seems a bit complicated for my needs. thanks</p>
  
  <p><a href="https://stackoverflow.com/questions/16241687/summarize-a-data-table-across-multiple-columns">how to summarize a data.table across multiple columns</a></p>