title: Filter R data frame by hour of the day
body: <p>I have a data frame with a datetime column. I want to know the number of rows by hour of the day. However, I care only about the rows between 8 AM and 10 PM.</p>
  
  <p>The <code>lubridate</code> package requires us to filter hours of the day using the 24-hour convention.</p>
  
  <pre class="lang-r prettyprint-override"><code>library(tidyverse)
  library(lubridate)
  
  ### Fake Data with Date-time ----
  x &lt;- seq.POSIXt(as.POSIXct('1999-01-01'), as.POSIXct('1999-02-01'), length.out=1000)
  
  df &lt;- data.frame(myDateTime = x)
  
  ### Get all rows between 8 AM and 10 PM (inclusive)
  
  df %&gt;% 
    mutate(myHour = hour(myDateTime)) %&gt;% 
    filter(myHour &gt;= 8, myHour &lt;= 22) %&gt;%  ## between 8 AM and 10 PM (both inclusive)
    count(myHour) ## number of rows
  </code></pre>
  
  <p>Is there a way for me to use <code>10:00 PM</code> rather than the integer <code>22</code>?</p>