title: R aggregate columns based on a factor column's value and create a new data frame
body: <p>I have following R data table:</p>
  
  <pre><code>&gt; head(dt)
        X0   X1   X2  X3   X4  X5 X6 X7  X8 X9 X10 X11 X12 X13 X14 X15 grp
  1: 33653 2325  916 720  867 187 31  0   6  3  42  56  92  15  69   0 a-4
  2: 18895  414 1116 570 1190  55 92  0 122 23  78   6   4   2  11   0 a-3
  3:  1383   70   27  17   17   1  0  0   0  0   1   0   0   0   3   0 a-6
  4:   396   72   34   5   18   0  0  0   0  0   0   0   0   0   0   0 a-5
  5:  3915 1170  402 832 2791 316 12  5 118 51  32   9  62  27   1   0 a-3
  6:   554   33  138  13  415   4  5  0   0  0   0   0   0   0   0   0 a-5
  </code></pre>
  
  <p>I want to create a new data frame that has column wise aggregation respect to value in the <code>grp</code> column. Based on above 6 records <code>row2</code>, and <code>row5</code> should be sum together as well as <code>row4</code> and <code>row6</code>, and new data table now have 4 rows instead of 6. </p>
  
  <p>I tried to use <code>ddply</code> as follows: </p>
  
  <pre><code>&gt; ddply(dt, numcolwise(sum))
  </code></pre>
  
  <p>but ended up getting following error: </p>
  
  <pre><code>Error in UseMethod("as.quoted") : 
    no applicable method for 'as.quoted' applied to an object of class "function"
  </code></pre>