0

I am trying to convert this t field to datetime in R. This is the vector:

dput(t)
"01-DEC-15 04.50.14.000000000 PM"

I tried this:

tt<-as.POSIXct(t, format="%d-%b-%Y %I.%M.%S %p")

when I print out the tt, I get NA. Any ideas what I'm doing wrong?

user1471980
  • 10,127
  • 48
  • 136
  • 235

1 Answers1

4
R> strptime("01-DEC-15 04.50.14.000000000 PM", 
+           "%d-%b-%y %I.%M.%S.000000000 %p")
[1] "2015-12-01 16:50:14 CST"
R> 

You were using the wrong qualifier for the year, and I am not sure that the am/pm toggle would have gotten that way.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725