title: Calculating Time Difference between two columns
body: <p>After converting factors in POSIXCT format and then applying datetime format, I want to take the difference of datetime between 2 pos1 and pos2. </p>
  
  <p>However, when I do that for a specific item I get the right answer in the console but when I do the operation on the whole set the console outputs just number and also the dateframe reflects those number as you can see.</p>
  
  <p>How can I get the hours in the dataframe when I am trying to take the difference?
  I am using lubridate package, is there any function to do so?</p>
  
  <p>Here is some example code/picture of the data in RStudio describing it</p>
  
  <pre><code>CR_Date &lt;- data.frame(
    pos1="2014-07-01 00:00:00",
    pos2=c("2014-07-01 00:00:00","2014-07-01 10:15:00")
  )
  CR_Date[] &lt;- lapply(CR_Date,as.POSIXct)
  CR_Date
  
  #        pos1                pos2
  #1 2014-07-01 2014-07-01 00:00:00
  #2 2014-07-01 2014-07-01 10:15:00
  
  CR_Date$pos2[2] - CR_Date$pos1[2]
  #Time difference of 10.25 hours
  CR_Date$hours &lt;- CR_Date$pos2 - CR_Date$pos1
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/BI3d8.png" alt="enter image description here"></p>