title: How to aggregate a dataframe by week?
body: <p>Consider the following example</p>
  <pre><code>library(tidyverse)
  library(lubridate)
  
  time &lt;- seq(from =ymd(&quot;2014-02-24&quot;),to= ymd(&quot;2014-03-20&quot;), by=&quot;days&quot;)
  set.seed(123)
  values &lt;- sample(seq(from = 20, to = 50, by = 5), size = length(time), replace = TRUE)
  df2 &lt;- data_frame(time, values)
  df2 &lt;- df2 %&gt;% mutate(day_of_week = wday(time, label = TRUE))
  
  Source: local data frame [25 x 3]
  
           time values day_of_week
         &lt;date&gt;  &lt;dbl&gt;      &lt;fctr&gt;
  1  2014-02-24     30         Mon
  2  2014-02-25     45        Tues
  3  2014-02-26     30         Wed
  4  2014-02-27     50       Thurs
  5  2014-02-28     50         Fri
  6  2014-03-01     20         Sat
  7  2014-03-02     35         Sun
  8  2014-03-03     50         Mon
  9  2014-03-04     35        Tues
  10 2014-03-05     35         Wed
  </code></pre>
  <p>I would like to aggregate this dataframe by week.</p>
  <p>That is, suppose I define a week as starting on Monday morning and ending on Sunday evening, which we will call a <code>Monday to Monday</code> cycle. (importantly, I want to be able to choose other conventions, such as Friday to Friday for instance).</p>
  <p>Then, I would simply like to count the mean of <code>values</code> for each week.</p>
  <p>For instance, in the example above, one would compute the average of <code>values</code> between Monday February 24th to Sunday March 2nd, and so on.</p>
  <p>How can I do that?</p>