title: trying to compare POSIXct objects in if statements
body: <p>I have something like this within a function:</p>
  
  <pre><code>x &lt;- as.POSIXct((substr((dataframe[z, ])$variable, 1, 8)), tz = "GMT", 
  format = "%H:%M:%S")
  print(x)
  if ( (x &gt;= as.POSIXct("06:00:00", tz = "GMT", format = "%H:%M:%S")) &amp;   
  (x &lt; as.POSIXct("12:00:00", tz = "GMT", format = "%H:%M:%S")) ){
  position &lt;- "first"
  }
  </code></pre>
  
  <p>but I get this output:</p>
  
  <blockquote>
    <p>character(0) 
    Error in if ((as.numeric(departure) - as.numeric(arrival)) &lt; 0) { :    argument is of length zero</p>
  </blockquote>
  
  <p>how can I fix this so my comparison works and it prints the correct thing?</p>
  
  <p>some examples of the dataframe$variable column:
      16:33:00
      15:34:00
      14:51:00
      07:26:00
      05:48:00
      11:10:00
      17:48:00
      06:17:00
      08:22:00
      11:31:00</p>