title: Subtracting the last value in a group from previous values in dplyr
body: <p>I have the following data</p>
  
  <pre><code>data = tribble(~t,~key,~value,
          1,"a",10,
          2,"a",20,
          3,"a",30,
          1,"b",100,
          2,"b",200,
          3,"b",300,
          1,"c",1000,
          2,"c",2000,
          3,"c",3000)
  </code></pre>
  
  <p>and would like to get the following result</p>
  
  <pre><code>result = tribble(~t,~key,~value,
          1,"a",-20,
          2,"a",-10,
          3,"a",0,
          1,"b",-200,
          2,"b",-100,
          3,"b",0,
          1,"c",-2000,
          2,"c",-3000,
          3,"c",0)
  </code></pre>
  
  <p>The idea is that I would like to subtract the 3rd value from all of the other values in that group. I tried to <code>group_by</code> the <code>key</code>, but struggled on the row wise subtraction within the group</p>