title: how to calculate proportion by another variable (not by frequency) in dplyr in R
body: <p>Using mtcars data, I want to calculate proportion of mpg for each group of cyl and am. How to calc it? </p>
  
  <pre><code>mtcars %&gt;%
     group_by(cyl, am) %&gt;%
     summarise(mpg = n(mpg)) %&gt;%
     mutate(mpg.gr = mpg/(sum(mpg))
  </code></pre>
  
  <p>Thanks in advance!</p>