title: aggregate data frame with many columns according to one column
body: <p>From a data frame of many columns, I would like to aggregate (i.e. <code>sum</code>) hundreds of columns by a single column, without specifying each of the column names.</p>
  
  <p>Some sample data:</p>
  
  <pre><code>names &lt;- floor(runif(20, 1, 5))
  sample &lt;- cbind(names)
  
  for(i in 1:20){
  col &lt;- rnorm(20,2,4)
  sample &lt;- cbind(sample, col)
  }
  </code></pre>
  
  <p>What I have until now is the following code, but it gives me that arguments must be the same length.</p>
  
  <pre><code>aggregated &lt;- aggregate.data.frame(sample[,c(2:20)], by = as.list(names),     FUN = 'sum')
  </code></pre>
  
  <p>Original dataset is a lot bigger, so I can't specify the name of each of the columns to be aggregated and I can't use the list function. </p>