0

There is following df:

data$time

 [1] 2012-06 2012-07 2012-08 2012-09 2012-10 2012-11 2012-12 2013-01 2013-02 2013-03 2013-04 2013-05 2013-06 ...

class(data$time)

[1] "factor"

I want to convert the column into date format:

as.Date(data$time)

Error in charToDate(x) : 
  character string is not in a standard unambiguous format

as.Date(data$time, format = "%Y-%m")

doesn't work either:

 [1] NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA NA ... (Batman?)

How can I solve this? I need to prepare data$time as Date, so that I can load it into zoo(data).

Thank you!

Fanny
  • 55
  • 11

0 Answers0