title: R, data.table, group by column *numbers* AND sum a column
body: <p>Let's say I have the following <strong>data.table</strong></p>
  
  <pre><code>&gt; DT
  #        A B C D E          N
  #     1: J t X D N 0.07898388
  #     2: U z U L A 0.46906049
  #     3: H a Z F S 0.50826435
  #    ---                     
  #  9998: X b R L X 0.49879990
  #  9999: Z r U J J 0.63233668
  # 10000: C b M K U 0.47796539
  </code></pre>
  
  <p>Now I need to group by a pair of columns and calculate sum N.
  That's easy to do when you know column names in advance:</p>
  
  <pre><code>&gt; DT[, sum(N), by=.(A,B)]
  #      A B        V1
  #   1: J t  6.556897
  #   2: U z  9.060844
  #   3: H a  4.293426
  #  ---              
  # 674: V z 11.439100
  # 675: M x  1.736050
  # 676: U k  3.676197
  </code></pre>
  
  <p>But I must do that in a <strong>function</strong>, which receives a vector of column indices to group by.</p>
  
  <pre><code>&gt; f &lt;- function(columns = 1:2) {
      DT[, sum(N), by=columns]
  }
  &gt; f(1:2)
  Error in `[.data.table`(DT, , sum(N), by = columns) : 
    The items in the 'by' or 'keyby' list are length (2). Each must be same 
    length as rows in x or number of rows returned by i (10000). 
  </code></pre>
  
  <p>I also tried:</p>
  
  <pre><code>&gt; f(list("A", "B"))
  Error in `[.data.table`(DT, , sum(N), by = list(columns)) : 
    column or expression 1 of 'by' or 'keyby' is type list. Do not quote column
    names. Usage: DT[,sum(colC),by=list(colA,month(colB))]
  </code></pre>
  
  <p>How do I make this to work?</p>