title: How to filter by multiple time ranges in R?
body: <p>I have a dataframe with a DateTime column and some other variables. Below is an example of it:</p>
  
  <pre><code>library(lubridate)
  df &lt;- tibble(DateTime = ymd_hms(c("2020-04-06 10:00:00", 
                                                      "2020-04-07 12:30:00", 
                                                      "2020-04-07 14:31:00", 
                                                      "2020-05-05 17:00:00")),
                                 Var1 = c(1,2,3,4),
                                 var2= c("a","b","c","d"))
  df
  # A tibble: 4 x 3
            DateTime             Var1 var2 
            &lt;dttm&gt;              &lt;dbl&gt; &lt;chr&gt;
          1 2020-04-06 10:00:00     1 a    
          2 2020-04-07 12:30:00     2 b    
          3 2020-04-07 14:31:00     3 c    
          4 2020-05-05 17:00:00     4 d   
  </code></pre>
  
  <p>I'd like to filter rows such that it returns a dataframe with the time element in DateTime being between: </p>
  
  <ul>
  <li><p>09:15:00 to 12:00:00 OR </p></li>
  <li><p>13:15:00 to 16:30:00 OR </p></li>
  <li>17:15:00 to 01:00:00.</li>
  </ul>
  
  <p>Such that it returns the following dataframe:</p>
  
  <pre><code># A tibble: 2 x 3
    DateTime             Var1 var2 
    &lt;dttm&gt;              &lt;dbl&gt; &lt;chr&gt;
  1 2020-04-06 10:00:00     1 a    
  2 2020-04-07 14:31:00     3 c 
  </code></pre>
  
  <p>I know I could do <code>DateTime &gt;= hms("09:15:00") &amp; DateTime &lt;= hms("12:00:00")</code> and so on but that seems way too complicated. Is there an easier way to do it?</p>