title: Aggregate data by equally spaced time intervals in R
body: <p>My dataset is something like this</p>
  
  <pre><code>Section Time  x
  s3      9:35  2
  s4      9:35  2
  s1      9:36  1
  s2     10:01  1
  s8     11:00  2
  </code></pre>
  
  <p>So, I want to group the data section wise on hourly interval and sum up the x values that lies in that interval</p>
  
  <p>My expected output is</p>
  
  <pre><code> sec     Time          x
   s1      9:00-10:00    1
   s2      9:00-10:00    0
   s3      9:00-10:00    2
   s4      9:00-10:00    2
   s8      9:00-10:00    0
   s1      10.00-11.00   0
   s2      10.00-11.00   1
   s3      10.00-11.00   0
   s4      10.00-11.00   0
   s8      10.00-11.00   1   
  </code></pre>
  
  <p>I tried to get some help from this post <a href="https://stackoverflow.com/questions/23401412/aggregate-a-data-frame-in-r-by-equally-spaced-time-intervals">in stack overflow</a>, but I am getting the following error for my this query. Here x is my frame</p>
  
  <pre><code>data.frame(value = tapply(cbind(x$x),
                       list(sec= x$section,cut(x$Time, breaks="1 hour")),
                         sum))
  
  Error in cut.default(x$Time, breaks = "1 hour") : 'x' must be numeric
  </code></pre>
  
  <p>I am not even sure if that is right or wrong. I never worked with time data in R. So any help on how can I achieve that would be a great help.</p>