title: R divide intervals in hourly slots
body: <p>probably very easy but struggling with it, looked for the answers on the web but they usually relate to <code>cut</code> and snapshots, not intervals overlapping</p>
  
  <pre><code>require(data.table)
  x = data.table(start=c("2017-04-18 18:05:00","2017-04-18 18:00:00", 
  "2017-04-18 21:05:00", "2017-04-18 16:05:00"), 
                 end=c("2017-04-18 19:05:00","2017-04-18 21:30:00",
  "2017-04-18 22:00:00", "2017-04-18 16:10:00"))
  </code></pre>
  
  <p>we have 4 observations and i need to allocate it to the corresponding hourly windows. </p>
  
  <pre><code>                 start                 end
  1: 2017-04-18 18:05:00 2017-04-18 19:05:00
  2: 2017-04-18 18:00:00 2017-04-18 21:30:00
  3: 2017-04-18 21:05:00 2017-04-18 22:00:00
  4: 2017-04-18 16:05:00 2017-04-18 16:10:00
  </code></pre>
  
  <p>the first one for example will have 55 min in 18:00 slot and 5 min in 19:00 slot, the next one 60 min in 18:00,19:00, 20:00 and 30 min in 21:00, the third one will have 55 min in 21:00 and the last one 5 min in 16:00</p>
  
  <p>the result should be as below (sorry if i got the basic manual additions wrong;)</p>
  
  <pre><code>              interval   Q
  1: 2017-04-18 16:00:00 5
  2: 2017-04-18 17:00:00 0
  3: 2017-04-18 18:00:00 115
  4: 2017-04-18 19:00:00 65
  5: 2017-04-18 20:00:00 120
  6: 2017-04-18 21:00:00  85
  </code></pre>
  
  <p>of course there is a straight forward way to cut the series by minutes and perform a count by cut/interval, but i believe the problem is so common it must have a direct method. Preferably i would have the 0 value windows as well, but i can just sequence them if required</p>