2

In my console :

> format(as.Date("2010-01-01"), format="%A")
[1] "星期五"

How to get the day of week in english not in chinese?
"星期五" is the chinese form of friday.

it is no use to set environment in my console.

> Sys.setenv(LANG = "en")
>  format(as.Date("2010-01-01"), format="%A")
[1] "星期五"

it is no use to edit /etc/Rconsole, Language=en .

> Sys.setlocale("LC_ALL", "en_US")
[1] ""
Warning message:
In Sys.setlocale("LC_ALL", "en_US") :
 OS reports request to set locale to "en_US" cannot be honored
>  format(as.Date("2010-01-01"), format="%A")
[1] "星期五"

my system is :xp+r -3.0.1.
i have edited the file /etc/Rprofile.site to add some lines:

.First <- function(){
Sys.setlocale("LC_COLLATE", "English")
Sys.setlocale("LC_CTYPE", "English")
Sys.setlocale("LC_MONETARY", "English")
Sys.setlocale("LC_TIME", "English")}  

is there an other way to do ? to edit some file ,not to load the commands in /etc/Rprofile.site when to start R?

showkey
  • 482
  • 42
  • 140
  • 295
  • The answer here may be relevant: http://stackoverflow.com/questions/13575180/how-to-change-the-language-of-errors-in-r/13575413#13575413 – Chase Oct 27 '13 at 01:49

2 Answers2

5

In the help file for strptime:

Locale-specific conversions to and from character strings are used where appropriate and available. This affects the names of the days and months, the AM/PM indicator (if used) and the separators in formats such as %x and %X (via the setting of the LC_TIME locale category).

The minimal change would be to change LC_TIME:

In Windows the command appears to be (from this question):

Sys.setlocale("LC_TIME", "English")

For Unix-like systems the command appears to be (from the same question):

Sys.setlocale("LC_TIME", "en_US.UTF-8")
Community
  • 1
  • 1
Blue Magister
  • 13,044
  • 5
  • 38
  • 56
0

Try setting the locale. For example:

Sys.setlocale("LC_ALL", "en_US")

The locales available to you will depend on your system. See the locales section of the R manual for some more information.

Peyton
  • 7,266
  • 2
  • 29
  • 29