title: Calculate the mean by group
body: <p>I have a large data frame that looks similar to this:</p>
  <pre><code>df &lt;- data.frame(dive = factor(sample(c(&quot;dive1&quot;,&quot;dive2&quot;), 10, replace=TRUE)),
                   speed = runif(10)
                   )
  &gt; df
      dive      speed
  1  dive1 0.80668490
  2  dive1 0.53349584
  3  dive2 0.07571784
  4  dive2 0.39518628
  5  dive1 0.84557955
  6  dive1 0.69121443
  7  dive1 0.38124950
  8  dive2 0.22536126
  9  dive1 0.04704750
  10 dive2 0.93561651
  </code></pre>
  <p>My goal is to obtain the average of values in one column when another column is equal to a certain value and repeat this for all values. i.e. in the example above I would like to return an average for the column <code>speed</code> for every unique value of the column <code>dive</code>. So when <code>dive==dive1</code>, the average for <code>speed</code> is this and so on for each value of <code>dive</code>.</p>