Skip to content

Month name in English, not R running language

3 messages · Marc Girondot, Pascal Oettli

#
When ploting a timeseries, the months are shown with abbreviation in the 
current language of the system.
For example,
x <- seq(from=as.Date("2000-04-01"), length.out=100, by=1)
y <- rnorm(length(x), 5,2)
plot(x, y)

Show for me "avi mai jui jul" as I use R with French language localization.

I see in the Windows FAQ how to completely change the language of R, but 
I search rather a way to change it for just the next command (also I run 
R in MacOS !).

The solution will be to make myself the axis... except if someone has 
the trick to do it more easily.

To generate the axis myself, it is not so simply to get one tick by 
month. I try
axTicks(1) but it gives 5 ticks rather than 4

and

 > as.Date(axTicks(1), "1970-01-01")
[1] "2000-04-13" "2000-05-03" "2000-05-23" "2000-06-12" "2000-07-02"
Is not what I expected. Plot with date object seems to use a special way 
to generate ticks.

Thanks a lot

Marc
#
Hello,

?Sys.setlocale

HTH,
Pascal

Le 15/01/2013 15:28, Marc Girondot a ?crit :
#
It works perfectly:
 > Sys.setlocale(category = "LC_TIME", locale="en_GB.UTF-8")
[1] "en_GB.UTF-8"
 > x <- seq(from=as.Date("2000-04-01"), length.out=100, by=1)
 > y <- rnorm(length(x), 5,2)
 > plot(x, y)
 > Sys.setlocale(category = "LC_TIME", locale="")
[1] "fr_FR.UTF-8"

Thanks a lot

Marc

(I post the solution on the list as I have had some difficulties to find 
the good format for locale parameter. It could help others)

Le 15/01/13 07:41, Pascal Oettli a ?crit :