title: Add numbers corresponding to different hours associated with two different dates in R
body: <p>I have the following dataframe</p>
  
  <pre><code>set.seed(1000) 
  data &lt;- data.frame(date = sort(rep(Sys.Date()-1:3, 5)), 
                     hour = rep(0:4, 3), 
                   values = round(rexp(15),2))
  
        date     hour  values
  1  2016-04-25    0   1.00
  2  2016-04-25    1   0.52
  3  2016-04-25    2   2.44
  4  2016-04-25    3   2.16
  5  2016-04-25    4   0.48
  6  2016-04-26    0   0.17
  7  2016-04-26    1   1.56
  8  2016-04-26    2   0.51
  9  2016-04-26    3   0.96
  10 2016-04-26    4   0.05
  11 2016-04-27    0   0.75
  12 2016-04-27    1   1.69
  13 2016-04-27    2   0.61
  14 2016-04-27    3   0.85
  15 2016-04-27    4   2.23
  </code></pre>
  
  <p>I want to add numbers correspondig to the column values, these numbers should be associated with the hours from </p>
  
  <p>2 to 1 closed. However, the number 2 correspond to one date, and the number 1 is associated with the next date.</p>
  
  <p>I want a final dataframe like</p>
  
  <pre><code>  date    sumvalue
  2016-04-26 6.81
  2016-04-27 3.96
  </code></pre>
  
  <p>Someone knows an elegant way to do this? I want to do the same with a huge dataframe.</p>
  
  <p>Kind regards</p>