title: Aggregate multiple rows of the same data.frame in R based on common values in given columns
body: <p>I have a <code>data.frame</code> that looks like this:</p>
  
  <pre class="lang-r prettyprint-override"><code># set example data
  df &lt;- read.table(textConnection("item\tsize\tweight\tvalue
  A\t2\t3\t4
  A\t2\t3\t6
  B\t1\t2\t3
  C\t3\t2\t1
  B\t1\t2\t4
  B\t1\t2\t2"), header = TRUE)
  
  # print example data
  df
  </code></pre>
  
  <pre class="lang-none prettyprint-override"><code>  item size weight value
  1    A    2      3     4
  2    A    2      3     6
  3    B    1      2     3
  4    C    3      2     1
  5    B    1      2     4
  6    B    1      2     2
  </code></pre>
  
  <p>As you can see the <code>size</code> and <code>weight</code> columns do not add any complexity since they are the same for each <code>item</code>. However, there can be multiple <code>value</code>s for the same <code>item</code>.</p>
  
  <p>I want to collapse the data.frame to have one row per <code>item</code> using the mean <code>value</code>:</p>
  
  <pre class="lang-none prettyprint-override"><code>  item size weight value
  1    A    2      3     5
  3    B    1      2     3
  4    C    3      2     1
  </code></pre>
  
  <p>I guess I have to use the <code>aggregate</code> function but I could not figure out how exactly I can get the above result.</p>