title: dplyr: lubridate: How to count the number of occurrences by week and spread on daily data
body: <p>Hi I have the next data frame</p>
  
  <pre><code>    report_date Revenue Day_type
  1   2017-01-01  260.96     Sale
  2   2017-01-02  540.12     Sale
  3   2017-01-03  511.59     Sale
  4   2017-01-04  343.29     Sale
  5   2017-01-05  507.09     Sale
  6   2017-01-06 1023.32     Sale
  7   2017-01-07  580.19     Sale
  8   2017-01-08  826.74     Sale
  9   2017-01-09  753.78     Sale
  10  2017-01-10  468.44     Sale
  11  2017-01-11  526.57     Sale
  12  2017-01-12  419.10     Sale
  13  2017-01-13  243.10  Avg day
  14  2017-01-14  456.64  Avg day
  15  2017-01-15  659.91  Avg day
  16  2017-01-16  516.98  Avg day
  17  2017-01-17  447.00     Sale
  18  2017-01-18  222.70     Sale
  19  2017-01-19  129.48     Sale
  20  2017-01-20  205.44     Sale
  </code></pre>
  
  <p>I am trying to group by week sum the revenue and then spread the Day_type column so it counts the number of occurrences on each week</p>
  
  <p>the final product should be like this</p>
  
  <pre><code>   year  week Revenue  Sale  Avg day
    &lt;dbl&gt; &lt;dbl&gt;   &lt;dbl&gt;
  1  2017     1   3767.   7      0
  2  2017     2   3694.   5      2
  3  2017     3   2320.   5      2
  4  2017     4   3315.   7      0
  5  2017     5   1998.   7      0
  6  2017     6   1757.   7      0
  </code></pre>
  
  <p>with this code I am able to group by week and sum the revenue, but I need help spreading and counting the Day_type column.</p>
  
  <pre><code>fulldata &lt;- fulldata %&gt;% 
    group_by(year = year(report_date), 
             week = week(report_date)) %&gt;% 
    summarise_if(is.numeric, sum) %&gt;% 
    summarise_if(is.factor, count)
  </code></pre>
  
  <p>Thanks for your help</p>