title: Sum between elements of a vector using indices of start and end positions
body: <p>I have a vector (in this case extracted from a data frame) that I would like to calculate a some sums from using a two additional vectors containing start and end indices of the data vector to be used.  For this, I am working in R.  </p>
  
  <p>For example, my vector to use for calculations is: </p>
  
  <pre><code>Data Vector:
  [1] 1.45
  [2] 1.56
  [3] 1.57
  [4] 1.40
  [5] 3.45
  [6] 1.45
  [7] 1.66
  [8] 2.03
  [9] 1.33
  </code></pre>
  
  <p>Using other information in my data frame, I have calculated two other vectors containing the index positions of the above vector which I have called "start" and "stop" to denote the ranges between which I want to sum values.  For example: </p>
  
  <pre><code>Start: 
  [1] 1 
  [2] 4
  [3] 7
  
  End: 
  [1] 3 
  [2] 6
  [3] 9
  </code></pre>
  
  <p>I would like to use these two index vectors to sum between elements 1-3, 4-6, and 7-9 in my data vector.  I'm struggling with a way to implement this across a data frame with several hundred rows.  </p>
  
  <p>I'm now attempting to write a function to do this, but wanted to put this up in case there is a simpler solution that I am missing. </p>