title: R computing the sum of a series
body: <p>Lets say I have a column of numbers such as below:</p>
  
  <pre><code>Y=
  1
  2
  3
  4
  5
  6
  34
  32
  23
  </code></pre>
  
  <p>I have an array <code>R1 = (1,3,7,8)</code></p>
  
  <p>I would like to achieve adding the elements of Y by making use of subscripts defined in R1.
  I need to generate an array of values like : The sum of numbers starting from Y[1] to Y[3] as my first element, sum of numbers starting from Y[3] to Y[7] as my 2nd element, sum from Y[7] to Y[8] as my third element and so on.</p>