title: R: Cut datetimes by time of day
body: <p>I have a <code>data_frame</code> with <code>POSIXct</code> date-times. I would now like to create a variable that cuts these date-times into timebands: 1 -- [00:00:00, 08:00:00), 2 -- [08:00:00, 17:00:00), 3 -- [17:00:00, 18:30:00), 4 -- [18:30:00, 00:00:00). </p>
  
  <p>Here is some sample data: </p>
  
  <pre><code>df_times = data_frame(
    datetime = seq.POSIXt(
      from = as.POSIXct(strftime("2016-01-01 00:00:00", format = "%Y-%m-%d :%H:%M:%S")),
      by = "min",
      length.out = 100000
    ),
    value = rnorm(100000)
  )
  </code></pre>
  
  <p>Here is the expected output: </p>
  
  <pre><code>&gt; df_times
  # A tibble: 100,000 × 3
                datetime      value  band
                  &lt;dttm&gt;      &lt;dbl&gt; &lt;dbl&gt;
  1  2016-01-01 00:00:00  0.5855288     1
  2  2016-01-01 00:01:00  0.7094660     1
  3  2016-01-01 00:02:00 -0.1093033     1
  4  2016-01-01 00:03:00 -0.4534972     1
  5  2016-01-01 00:04:00  0.6058875     1
  6  2016-01-01 00:05:00 -1.8179560     1
  7  2016-01-01 00:06:00  0.6300986     1
  8  2016-01-01 00:07:00 -0.2761841     1
  9  2016-01-01 00:08:00 -0.2841597     1
  10 2016-01-01 00:09:00 -0.9193220     1
  # ... with 99,990 more rows
  </code></pre>
  
  <p>I have tried <code>cut.POSIXt</code> but that insists on keeping track of dates. An ideal solution will use <code>dplyr::recode</code> or <code>forcats::</code>.</p>