Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the locale of R?

Tags:

r

locale

I’m using R version 2.15.3 (2013-03-01) on Ubuntu 12.10. The System is in German and so is R. This comes unhandy when searching for error messages.

Executing R in xterm this way $ LANG="C" R partially solves the issue. Then R displays everything in English. But when loading RStudio this way, the R interpreter is still in German. So I’m looking for a way to change the locale of R in R itself.

I found this: How to change language settings in R, but Sys.setenv(LANG = "en") does’t work for me:

2+x # Fehler: Objekt 'x' nicht gefunden Sys.setenv(LANG = "en") 2+x # Fehler: Objekt 'x' nicht gefunden 

I also tried Sys.setenv(LANG = "en_US.UTF-8") with no success.

Output of Sys.getlocale()

Sys.getlocale() # [1] "LC_CTYPE=de_DE.UTF-8;LC_NUMERIC=C;LC_TIME=de_DE.UTF-8; # LC_COLLATE=de_DE.UTF-8;LC_MONETARY=de_DE.UTF-8;LC_MESSAGES=de_DE.UTF-8; # LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=de_DE.UTF-8; # LC_IDENTIFICATION=C" 

(linebrakes added for convenience)

like image 832
Tobias Schula Avatar asked May 02 '13 21:05

Tobias Schula


People also ask

What is R locale?

The goal of readr's locales is to encapsulate common options that vary between languages and localities. This includes: The names of months and days, used when parsing dates. The default time zone, used when parsing datetimes. The character encoding, used when reading non-ASCII strings.


1 Answers

Just had the same problem and found the solution that worked for me on Windows/Linux:

Sys.setlocale("LC_ALL","English") 
like image 57
Andi Avatar answered Oct 02 '22 17:10

Andi