title: R data.table: reuse an aggregation
body: <p>I want to apply the same aggregation to multiple data tables, without rewriting the aggregation scheme.</p>
  
  <p>Consider</p>
  
  <pre><code>dt1 &lt;- data.table(id = c(1,2), a = rnorm(10), b = rnorm(10), c = rnorm(10))
  dt2 &lt;- data.table(id = c(1,2), a = rnorm(10), b = rnorm(10), c = rnorm(10))
  
  dt1_aggregates &lt;- dt1[, .(mean_a=mean(a), sd_a=sd(a), mean_b=mean(b), sd_b=sd(b)), by=id]
  dt2_aggregates &lt;- dt2[, .(mean_a=mean(a), sd_a=sd(a), mean_b=mean(b), sd_b=sd(b)), by=id]
  </code></pre>
  
  <p>Is there some way to reuse the dt1_aggregates aggregation scheme for dt2 without having to write it out twice?</p>