title: Can I use dplyr::mutate to operate on different rows?
body: <p>I have a dataset, I'm including (a small subset) of the relevant columns below,  </p>
  
  <pre><code>year ID type result  
  2003 1   new        closed  
  2003 2   new        transferred  
  2003 3   subsequent closed  
  2003 4   subsequent diverted  
  ....  
  2015 1000 new       closed
  </code></pre>
  
  <p>What I want to calculate is the fraction of subsequents, (no. of subsequents/(no.subsequents +no. of news) grouped by year and result, like so:</p>
  
  <pre><code>year result subsequent_frac  
  2003 closed 0.10  
  2003 transferred 0.05  
  2003 ....  
  ....  
  2015 closed 0.05  
  2015 transferred 0.1  
  </code></pre>
  
  <p>I know I can do in in steps, with a group_by and summaries to get the counts and and do each result separately.... I was wondering if there was a neater/faster way to do this. </p>