title: Aggregate multiple columns at once
body: <p>I have a data-frame likeso:</p>
  
  <pre><code>x &lt;-
  id1 id2    val1  val2 val3 val4
  1   a   x    1    9
  2   a   x    2    4
  3   a   y    3    5
  4   a   y    4    9
  5   b   x    1    7
  6   b   y    4    4
  7   b   x    3    9
  8   b   y    2    8
  </code></pre>
  
  <p>I wish to aggregate the above by id1 &amp; id2. I want to be able to get the means for val1, val2, val3, val4 at the same time.</p>
  
  <p>How do i do this?</p>
  
  <p>This is what i currently have but it works just for 1 column:</p>
  
  <pre><code>agg &lt;- aggregate(x$val1, list(id11 = x$id1, id2= x$id2), mean)
  names(agg)[3] &lt;- c("val1")  # Rename the column
  </code></pre>
  
  <p>Also, how do i rename the columns which are outputted as means in the same statement given above</p>