[R] Language issue

Duncan Murdoch murdoch at stats.uwo.ca
Thu Sep 8 00:49:58 CEST 2005


Sebastien Durand wrote:
> Dear all,
> 
> I am running
> R : Copyright 2005, The R Foundation for Statistical Computing
> Version 2.1.1  (2005-06-20), ISBN 3-900051-07-0
> Under Mac os X, a french version!
> 
> I am preparing a package and I got the following issue
> 
> I am trying to read dates that are written in 
> english and have them recognized by R using 
> as.Date function.
> 
> I realized strangely that when I type
> 
>> month.abb
> 
>   [1] "Jan" "Feb" "Mar" "Apr" "May" "Jun" "Jul" "Aug" "Sep" "Oct"
> [11] "Nov" "Dec"
> 
> I get the abbreviated english version of every month
> 
> 
>> x <- c("1-jan-1960", "2-feb-1960", 
>>"31-mar-1960", "30-apr-1960","2-may-1960", 
>>"31-jun-1960", "30-jul-1960","2-aug-1960", 
>>"31-sep-1960", "30-oct-1960", "30-nov-1960", 
>>"30-dec-1960");
>> strptime(x, "%d-%b-%Y")
> 
>   [1] "1960-01-01" NA           "1960-03-31" NA
>   [5] NA           NA           "1960-07-30" NA
>   [9] "1960-10-01" "1960-10-30" "1960-11-30" NA
> 
> It is only once I have found through trial an 
> error the french abbreviation, that I got a match 
> for every month.
> 
> 
>> x <- c("1-jan-1960", "2-fév-1960", 
>>"31-mar-1960", "30-avr-1960","2-mai-1960", 
>>"31-jui-1960", "30-jul-1960","2-aoû-1960", 
>>"31-sep-1960", "30-oct-1960", "30-nov-1960", 
>>"30-déc-1960");
>> strptime(x, "%d-%b-%Y")
> 
>   [1] "1960-01-01" "1960-02-02" "1960-03-31" "1960-04-30"
>   [5] "1960-05-02" "1960-07-01" "1960-07-30" "1960-08-02"
>   [9] "1960-10-01" "1960-10-30" "1960-11-30" "1960-12-30"
> 
> I got simply two questions:
> 
> First, why since R was install on a french system 
> the month.abb command didn't give me the french 
> abbreviations.

It is documented to give English names.  It might be an idea to have a 
variable that gives months in the local language, but I don't know if 
the current translation system supports that.  It would need to have a 
different name than month.abb.
> 
> Secondly, since I am producing a package, I would 
> like to know how can I tell R  to momentairly use 
> the english abbreviations instead of the french 
> ones...

I don't know, but I'd try Sys.setlocale().

Duncan Murdoch




More information about the R-help mailing list