0
votes

Problem occurs when months' value are in the text form like "Jan" or "January". for example, the following line

as.yearmon("Jan-2000", "%b-%Y")

returns an error:

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

what's going wrong here?

sessionInfo():

R version 2.15.1 (2012-06-22) Platform: x86_64-pc-mingw32/x64 (64-bit)

locale: [1] LC_COLLATE=Russian_Russia.1251 LC_CTYPE=Russian_Russia.1251 LC_MONETARY=Russian_Russia.1251 [4] LC_NUMERIC=C LC_TIME=Russian_Russia.1251

attached base packages: [1] grid stats graphics grDevices utils datasets methods base

other attached packages: [1] RODBC_1.3-6 latticeExtra_0.6-24 lattice_0.20-10 gplots_2.11.0 MASS_7.3-22
[6] KernSmooth_2.23-8 caTools_1.13 bitops_1.0-4.1 gdata_2.12.0 gtools_2.7.0
[11] RColorBrewer_1.0-5 xts_0.8-6 zoo_1.7-8

loaded via a namespace (and not attached): [1] tools_2.15.1

1
Works for me with R-2.15.1 and zoo_1.7-7. Please add the output from sessionInfo() to your question.Joshua Ulrich

1 Answers

2
votes

The problem is probably connected to LC_TIME locale settings (thanks Joshua for asking sessionInfo() output that tipped for the solution). So changing time locale helps.

loc <- Sys.getlocale("LC_TIME") #save current locale for future restore
Sys.setlocale("LC_TIME", "C")
as.yearmon("Jan-2000", "%b-%Y")

the result is

[1] "Jan 2000"