title: In R, assigning a number to a date, where the number corresponds to the nth rolling, non-overlapping period in a year that the date is included in
body: <p>I need to calculate rolling but non-overlapping 7-day means in a huge dataset so that I can calculate the number of 7-day mean exceedences (means above a certain threshold) for each station.  The dataset looks something like this:</p>
  
  <pre><code>STATION  DATE         VALUE
  A   1/15/2010   4
  A   1/18/2010   5
  A   1/25/2011   2
  A   1/30/2011   1
  A   2/2/2011    14
  B   5/6/2012    6
  B   5/14/2012   4
  B   5/17/2012   3
  B   1/29/2013   16
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <pre><code>STATION DATE         VALUE  7DAYPERIOD  YEAR-7DAYPERIOD
  A   1/15/2010   4   1   2010-1
  A   1/18/2010   5   1   2010-1
  A   1/25/2011   2   1   2011-1
  A   1/30/2011   1   1   2011-1
  A   2/2/2011    14  2   2011-2
  B   5/6/2012    6   1   2012-1
  B   5/14/2012   4   2   2012-2
  B   5/17/2012   3   2   2012-2
  B   1/29/2013   16  1   2013-1
  </code></pre>
  
  <p>where the "7DAYPERIOD" corresponds to the nth non-overlapping 7-day period relative to the earliest date in a year for a station.  I was then going to concatenate the year with this number ("YEAR-7DAYPERIOD") and then aggregate by this identifier and station to calculate the means for each station. </p>
  
  <p>I initially thought that lubridate "week" would help me out with this.  But "week" gives a number relative to January 1st.  I need the number to be relative to the earliest date in the year that is represented in the dataset AND have it be specific for a station. </p>