title: Relative frequencies / proportions with dplyr
body: <p>Suppose I want to calculate the proportion of different values within each group. For example, using the <code>mtcars</code> data, how do I calculate the <em>relative</em> frequency of number of <strong>gears</strong> by <strong>am</strong> (automatic/manual) in one go with <code>dplyr</code>?</p>
  
  <pre><code>library(dplyr)
  data(mtcars)
  mtcars &lt;- tbl_df(mtcars)
  
  # count frequency
  mtcars %&gt;%
    group_by(am, gear) %&gt;%
    summarise(n = n())
  
  # am gear  n
  #  0    3 15 
  #  0    4  4 
  #  1    4  8  
  #  1    5  5 
  </code></pre>
  
  <p>What I would like to achieve:</p>
  
  <pre><code>am gear  n rel.freq
   0    3 15      0.7894737
   0    4  4      0.2105263
   1    4  8      0.6153846
   1    5  5      0.3846154
  </code></pre>