title: sequential subtraction in r
body: <p>I would highly appreciate if somebody could help me out with this. This looks simple but I have no clue how to go about it. </p>
  
  <p>I am trying to work out the percentage change in one row with respect to the previous one. For example: my data frame looks like this:</p>
  
  <pre><code>day          value  
  
   1           21
   2           23.4
   3           10.7
   4           5.6 
   5           3.2
   6           35.2  
   7           12.9
   8           67.8
   .            .
   .            .  
   .            .
   365         27.2
  </code></pre>
  
  <p>What I am trying to do is to calculate the percentage change in each row with respect to previous row. For example:</p>
  
  <pre><code> day              value   
  
   1                  21
   2          (day2-day1/day1)*100
   3          (day3-day2/day2)*100
   4          (day4-day3/day3)*100 
   5          (day5-day4/day4)*100
   6          (day6-day5/day5)*100  
   7          (day7-day6/day6)*100
   8          (day8-day7/day7)*100
   .                  .
   .                  .  
   .                  .
   365        (day365-day364/day364)*100
  </code></pre>
  
  <p>and then print out only those days where the there was a percentage increase of >50% from the previous row</p>
  
  <p>Many thanks</p>