Error convering character value to monthly data with as.yearmon (zoo)

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?


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


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"


 ? Error convering character value to monthly data with as.yearmon (zoo)
 ? Error convering character value to monthly data with as.yearmon (zoo)
 ? R: converting data frame to zoo: Error in
 ? duplicate row.names (index) error in zoo
 ? as.yearmon in zoo not working correctly
 ? Using the 'zoo package' in R to sum data for a month
 ? How do create monthly series with zoo function
 ? Installing Zoo for R seems to be successful, but gives `Error object 'zoo' not found
 ? Add missing xts/zoo data with linear interpolation in R
 ? How to get the system time zone with a city name?