title: subset data.frame using POSIXct vector R
body: <p>I'm trying to  extract a range of POSIXct dates from a data frame</p>
  
  <p>with a sample data frame (data)...  </p>
  
  <pre><code>library(lubridate)
  start &lt;- as.POSIXct('2016-10-08 20:00:00')  
  time &lt;- seq(start, start + days(1), by = "30 min")  
  variable &lt;- sample(seq(from = 20, to = 50), size = 49, replace = TRUE)  
  data &lt;- data.frame(time, variable)  
  </code></pre>
  
  <p>I'm trying to create an indexed vector of date, using both a single date as well as a range.  I was going to initially subset the data frame, then extract the date column using the <code>$</code> operator (although I'm sure there is a more elegant way to do it).  </p>
  
  <pre><code>data_trim &lt;- data[c('2016-10-08 20:00:00', '2016-10-08 22:0:00' %--% '2016-
  10-09 13:00:00'),]
  </code></pre>
  
  <p>but the output is </p>
  
  <pre><code>     time variable
  NA   &lt;NA&gt;       NA
  NA.1 &lt;NA&gt;       NA
  </code></pre>
  
  <p>does anyone have any suggestions?</p>
  
  <p>Thank you</p>