Calculate mean of values based on matching strings in R : <p>Say I have a dataframe <code>df</code>:</p>

<pre><code>c1   c2
A    1
A    3
A    1
A    3
B    3
B    3
B    3
</code></pre>

<p>I want to use this dataframe to generate a table that shows each unique value from <code>c1</code> and the mean of its corresponding values from <code>c2</code>, resulting in this:</p>

<pre><code>v1   v2
A    2
B    3
</code></pre>

<p>because the mean of A's values is 2 ((1+1+3+3)/4) and B's is 3 ((3+3+3)/3).</p>

<p>I'm guessing I need to use aggregate but I'm not sure how.</p>
