0

I have a script on my desktop that works fine, but I had to migrate to Windows Server 2012 for work and now I'm getting a weird bug.

I'm trying to convert a mon-yr date format string to a zoo date using the as.yearmon() zoo function.

This works fine on Windows 7 for me but on Windows Server I get the result below:

>  x = c("Apr-13", "Aug-12", "Aug-13", "Dec-12", "Feb-13", "Jan-13", "Jul-13", "Jun-13", "Mar-13",     "May-13", "Nov-12", "Oct-12", "Sep-12")

> as.yearmon(x, "%b-%y")

[1] "Apr 2013" "Aug 2012" "Aug 2013" NA "Feb 2013" "Jan 2013" "Jul 2013" "Jun 2013"
[9] NA  NA  "Nov 2012" NA  "Sep 2012"

The NAs should not be there. I get dates on my desktop. Any ideas on where this could be coming from?

Dirk Calloway
  • 2,569
  • 4
  • 23
  • 34
  • 3
    You may check your "locale": `Sys.getlocale("LC_TIME")`. The abbreviation of month in your new locale is possibly different from the one in `x`. If so, you may try to set the locale. See `?locales`. "`LC_TIME` may affect the behaviour of `as.POSIXlt` and `strptime` and functions which use them" – Henrik Nov 05 '13 at 13:30
  • Yep, that was it... The server region was set to Germany. – Dirk Calloway Nov 05 '13 at 13:42
  • @Dirk - you should post that as the answer. – Carl Witthoft Nov 05 '13 at 13:57

1 Answers1

1

The problem was that the Regional Settings for the server were German even though the language was in English.

Used:

Control Panel> Region > Format

I changed this to English(US) and the function ran normally.

Dirk Calloway
  • 2,569
  • 4
  • 23
  • 34