title: Applying a function to all columns of a data.table together with a group-by
body: <p>I have a <code>data.table</code> with a large number of rows. I want to group the data table by one particular column, and I want to apply the same aggregation function to all the other columns. What is the appropriate way of doing that?</p>
  
  <p>Here is some sample code to set up a data table that looks similar to what I have.</p>
  
  <pre><code>my.table.tmp &lt;- matrix(runif(5000*95), nrow=5000)
  my.table &lt;- data.table(my.table.tmp)
  my.table[, gbc:=rep(c('A', 'B', 'C', 'D', 'E'), 1000)]
  </code></pre>
  
  <p>I want to group the table by the factor column <code>gbc</code>, and I want that all the remaining 95 columns should be aggregated by a function, let's say <code>mean</code>.</p>
  
  <p>I see that </p>
  
  <pre><code>my.table[, lapply(.SD, mean), by=gbc]
  </code></pre>
  
  <p>gives me a table with the correct dimensions, but I am not sure if this is doing the right thing. If it is doing the right thing, can someone help me by breaking down what's happening here? </p>