1

I am trying to change the system locale in r studio.

I used this code:

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

But when I restart Rstudio it reverts back to the previous locale

How can I fix this issue?

3
  • Do you want to set the locale for the entire system or just for R (or RStudio) sessions? Commented Jun 2, 2021 at 12:05
  • Just for R (RStudio) sessions Commented Jun 2, 2021 at 12:09
  • In that case, the answer by Waldi should work. Commented Jun 2, 2021 at 12:32

1 Answer 1

6

You could create or edit .Rprofile, at user's level, or at project's level, see.
For all R sessions (and hence RStudio sessions), this should work:

file.edit(file.path("~", ".Rprofile")) 

add in .Rprofile:

Sys.setlocale("LC_ALL","English") 
Sign up to request clarification or add additional context in comments.

1 Comment

An equivalent (but more general ?) solution is to use the etc/ directory each R installation has and to set Rprofile.site. Or. of you wish use Renviron.site which can use the short LC_ALL=English form as could ~/.Renviron. It all amounts to the same: set the env var when R starts as it cannot be set later. All this is detailed in help(Startup) which has been referenced a few times here over the years.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.