title: R: increase value of element in vector 'a' by adding the value from another vector 'b' to the previous element in vector 'a'
body: <p>I have data for a time relevant response. The data is grouped by factors though the timestamp is not such that instead of having start time at 0ms for factor <code>a</code>, the start time is more like 1901ms and end time is 2801ms. Factor <code>b</code> then picks up where factor a ends and so forth. I subsetted the data by factor and calculated the difference between each data collected row for that group. </p>
  
  <p>I would like to use the difference calculation to create a vector that starts at 0 and increases by adding the calculated difference stored in another vector. </p>
  
  <p>For example if the difference vector looks like this:</p>
  
  <pre><code>difference_vector &lt;- c(5, 2, 1, 6)
  </code></pre>
  
  <p>I need a new <code>timestamp</code> vector that looks like this:  </p>
  
  <pre><code>timestamp &lt;- c(0, 5(0+5), 7(5+2), 8(7+1), 14(8+6))
  </code></pre>
  
  <p>Thank you !</p>