title: Same difference in alternate rows per sub group
body: <p>I have data frame where i need to find difference but for every alternate row the difference should stay same as the things to do are same like this:</p>
  
  <p><a href="https://i.stack.imgur.com/oibZX.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oibZX.jpg" alt="enter image description here"></a></p>
  
  <p>but I have used this:</p>
  
  <pre><code>things &lt;- data.frame( category = c("A","B","A","B","A","B","A","B","A","B"),
                        things2do = c("ball","ball","bat","bat","hockey","hockey","volley ball","volley ball","foos ball","foos ball"),
                        number = c(12,5,4,1,0,2,2,0,0,2))
  
  
      things %&gt;% 
        mutate(diff = number - lead(number,order_by=things2do))
  </code></pre>
  
  <p>but it is not helpful,as I am getting this:
  <a href="https://i.stack.imgur.com/K6sTn.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/K6sTn.jpg" alt="enter image description here"></a></p>
  
  <p>Can i get some help here?</p>