title: how to calculate time difference over midnight?
body: <p>I have been stuck on this situation. I need to find time difference between start time and end time. I have tried different methods, but most of the time its either R is not recognising the code or giving me negative times when it passes midnight.</p>
  <p>I used this code:</p>
  <pre><code>df &lt;-   difftime(com_21$start_time,com_21$end_time, units = &quot;mins&quot;)
  com_21$ride_length &lt;- df
  </code></pre>
  <p>where com_21 is the name of my data frame.</p>
  <p>Data frame:<br />
  <img src="https://i.stack.imgur.com/dKwiN.png" alt="data frame" /></p>
  <p>Data type using <code>class()</code>:
  <img src="https://i.stack.imgur.com/tf4T2.png" alt="data type using class()" /></p>