title: Mutate each row in group according to the first row of the group
body: <p>For example, I have a data frame:</p>
  
  <pre><code>df &lt;- data.frame(grp = c(1,1,1,1,1,2,2,2,2,2),
                   idx = c(1,2,3,4,5,1,2,3,4,5),
                   val = c(4,6,1,7,2,8,5,3,9,1))
  </code></pre>
  
  <p>I want to divide the val of each row by the val of the first row in each group. The only way I found is to introduce a new column:</p>
  
  <pre><code> df %&gt;% group_by(grp) %&gt;%
          arrange(idx) %&gt;%
          mutate(t = ifelse(row_number(idx) == 1, val, 0)) %&gt;%
          mutate(val = val / sum(t))
  </code></pre>
  
  <p>Is there any simple way to do this?</p>