0

I was trying to find an answer to my question as mentioned above. I am trying to calculate the minutes difference between datetime formated cells in two separate columns. However, the input is already in POSIXlt and it seams (for me also understandably because not a numeric representation) that no calculations are possible. Using difftime I only receive NA output. Trying to use as.POSIXct() does not change the class of the variables.

Help is much appreciated and since being new here I hope I phrased the question correctly.

Thanks!

  • 1
    Shouldn't `difftime` with two POSIXlt values give you the time difference in whatever units you choose? For example, `x=as.POSIXlt("1990-01-01 12:00:56"); y=as.POSIXlt("1990-01-02 04:03:12"); difftime(x,y, units="secs")`. Or you can just do `x - y`. – eipi10 Apr 14 '16 at 23:12
  • And it works in `data.frame`s too - `df <- data.frame(one=Sys.time(), two=Sys.time()+10 ); df[] <- lapply(df, as.POSIXlt)` then `difftime(df$two, df$one)` – thelatemail Apr 14 '16 at 23:21
  • Thanks for the reply. The issue I have is that the format of the datetime in my df is: d/mm/yyyy hh:mm Now, it is classified as POSIXlt when I run class() but the above mentioned and by you indicated functions only return NA – Jannik12 Apr 15 '16 at 02:01

0 Answers0