title: Binning data by time in R
body: <p>I have this time sequence dataframe (df) that was collected in 5-second intervals. Each time value is repeated for each ID value (only IDs 1001 and 1002 are shown). I want to be able to bin/sum the Data column by each minute interval for each ID.</p>
  <pre><code>Time                    ID      Data
  2010-01-10 13:45:00     1001    0
  2010-01-10 13:45:05     1001    1
  2010-01-10 13:45:10     1001    0
  2010-01-10 13:45:15     1001    1
  ....
  2010-01-10 13:45:00     1002    0
  2010-01-10 13:45:05     1002    0
  2010-01-10 13:45:10     1002    0
  2010-01-10 13:45:15     1002    1
  ....
  </code></pre>
  <p>Here's a reproducible example:</p>
  <pre><code>library(lubridate)
  library(tidyverse)
  
  # generate minimal example
  df &lt;- tibble(
    Time = rep(
      seq(
        ymd_hms(&quot;2010-01-10 00:00:00&quot;), 
        ymd_hms(&quot;2010-01-10 23:59:55&quot;), 
        &quot;5 sec&quot;),
      2
    )
  )
  
  df$ID   &lt;- rep(c(&quot;1001&quot;,&quot;1002&quot;), each = nrow(df)/2)
  df$Data &lt;- rnorm(nrow(df))
  </code></pre>
  <p>I want my output dataframe to look like</p>
  <pre><code>Time               ID         Data
  2010-01-10 13:45   1001       2
  2010-01-10 13:46   1001       
  2010-01-10 13:47   1001  
  2010-01-10 13:45   1002       1
  2010-01-10 13:46   1002
  2010-01-10 13:47   1002  
  </code></pre>