title: Sum a variable based on another variable
body: <p>I have a dataset consisting of two variables, <code>Contents</code> and <code>Time</code> like so:</p>
  
  <pre><code>Time          Contents
  2017M01       123
  2017M02       456
  2017M03       789
  .             .
  .             .
  .             .
  2018M12       789
  </code></pre>
  
  <p>Now I want to create a numeric vector that aggregates <code>Contents</code> for six months, that is I want to sum <code>2017M01</code> to <code>2017M06</code> to one number, <code>2017M07</code> to <code>2017M12</code> to another number and so on.</p>
  
  <p>I'm able to do this by indexing but I want to be able to write: "From 2017M01 to 2017M06 sum contents corresponding to that sequence" in my code.</p>
  
  <p>I would really appreciate some help!</p>