code

R에서 언어 설정을 변경하는 방법

codestyles 2020. 9. 1. 07:32
반응형

R에서 언어 설정을 변경하는 방법


내 오류 메시지가 프랑스어로 표시됩니다. 오류 메시지가 영어로 표시되도록 시스템 언어 설정을 변경하려면 어떻게해야합니까?


Sys.setenv()기능을 사용하여 설정할 수 있습니다 . 내 R 세션은 기본적으로 영어로 설정되어 있으므로 프랑스어로 설정 한 다음 다시 돌아갑니다.

> Sys.setenv(LANG = "fr")
> 2 + x
Erreur : objet 'x' introuvable
> Sys.setenv(LANG = "en")
> 2 + x
Error: object 'x' not found

약어 목록은 여기 에서 찾을 수 있습니다 .

Sys.getenv() 설정된 모든 환경 변수의 목록을 제공합니다.


Windows 용 RStudio의 경우 R for Windows FAQ 에있는 지침에 따라 언어를 변경하는 데 성공했습니다 . 특히 다음과 같이 작성했습니다.

language = EN

파일 내부 Rconsole(내 설치에서는 C:\Program Files\R\R-2.15.2\etc\Rconsole); 이것은 명령에도 적용 Rscript됩니다.

예를 들어 Rconsole명령 프롬프트에서 다음 두 명령을 사용 하여 파일을 찾을 수 있습니다 .

cd \

dir Rconsole /s

첫 번째는 루트를 현재 디렉토리로 만들고 두 번째는 Rconsole파일을 찾습니다 .

다음 스크린 샷 Rconsole에서 해당 파일이 폴더에 C:\Program Files\R\R-3.4.1\etc있습니다.

둘 이상의 위치가있을 수 있으며이 경우 모든 Rconsole파일을 편집 할 수 있습니다.

여기에 이미지 설명 입력

그런 Rconsole다음 좋아하는 편집기로 파일을 열고 language =을 찾은 다음 EN해당 줄의 끝에 추가 할 수 있습니다.

다음 스크린 샷에서 흥미로운 줄은 숫자 70이며 EN그 끝에 추가해야 합니다.여기에 이미지 설명 입력


Mac 사용자의 경우 R for Mac FAQ 에서 찾았습니다.

If you use a non-standard setup (e.g. different language than formats), you can override the auto-detection performed by setting `force.LANG' defaults setting, such as for example

 defaults write org.R-project.R force.LANG en_US.UTF-8 

when run in Terminal it will enforce US-english setting regardless of the system setting. If you don't know what Terminal is you can use this R command instead:

 system("defaults write org.R-project.R force.LANG en_US.UTF-8") 

but do not forget to quit R and start R.app again afterwards. Please note that you must always use `.UTF-8' version of the locale, otherwise R.app will not work properly.

This helped me to change my console language from Chinese to English.


This works from command line :

$ export LANG=en_US.UTF-8

None of the other answers above worked for me


If you use Ubuntu you will set

LANGUAGE=en 

in /etc/R/Renviron.site.


You may also want to be aware of the difference between, for example, Sys.setenv(LANG = "ru") and Sys.setlocale(locale = "ru_RU.utf8").

> Sys.setlocale(locale = "ru_RU.utf8")
[1] "LC_CTYPE=ru_RU.utf8;LC_NUMERIC=C;LC_TIME=ru_RU.utf8;LC_COLLATE=ru_RU.utf8;LC_MONETARY=ru_RU.utf8;LC_MESSAGES=en_IE.utf8;LC_PAPER=en_IE.utf8;LC_NAME=en_IE.utf8;LC_ADDRESS=en_IE.utf8;LC_TELEPHONE=en_IE.utf8;LC_MEASUREMENT=en_IE.utf8;LC_IDENTIFICATION=en_IE.utf8"

If you are interested in changing the behaviour of functions that refer to one of these elements (e.g strptime to extract dates), you should use Sys.setlocale(). See ?Sys.setlocale for more details. In order to see all available languages on a linux system, you can run

system("locale -a", intern = TRUE)

type this first: system("defaults write org.R-project.R force.LANG en_US.UTF-8") then you will get a index number(in my case is 127)

then type: Sys.setenv(LANG = "en") then type the number and ENTER 127


A simple solution would be setting export Lang=C in your bash script. I had a similar issue where the default language was german so it reverted back to english.


For me worked:

Sys.setlocale("LC_MESSAGES", "en_US.utf8")

Testing:

> Sys.setlocale("LC_MESSAGES", "en_US.utf8")
[1] "en_US.utf8"
> x[3]
Error: object 'x' not found

Also working to get english messages:

Sys.setlocale("LC_MESSAGES", "C")

To reset to german messages I used

Sys.setlocale("LC_MESSAGES", "de_DE.utf8")

Here is the start of my sessionInfo:

> sessionInfo()
R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.2 LTS

If you want to change R's language in terminal to English forever, this works fine for me in macOS:

Open terminal.app, and say:

touch .bash_profile

Then say:

open -a TextEdit.app .bash_profile

These two commands will help you open ".bash_profile" file in TextEdit.

Add this to ".bash_profile" file:

export LANG=en_US.UTF-8

Then save the file, reopen terminal and type R, you will find it's language has changed to english.

If you want language come back to it's original, just simply add a # before export LANG=en_US.UTF-8.


you simply have to change the basic language of microsoft on your computer!

press the windows button together with r, and tip the following code into the window that is opened

control.exe /name Microsoft.Language

load the language package you want to use and change the options. but take care, this will change also your keyboard layout!


In Ubuntu 14.04 LTS I had to remove the # from the comment #LANGUAGE=EN.
All other options din not work for me.


The only thing that worked for me was uninstalling R entirely (make sure to remove it from the Programs files as well), and install it, but unselect Message Translations during the installation process. When I installed R, and subsequently RCmdr, it finally came up in English.


on windows, when you have no admin right, just create a new program shortcut to Rgui.exe. Then in the properties of that shortcut, go to the 'Shortcut' tab and modify the target to include the system language of your choice, e.g. "C:\Program Files\R\R-3.5.3\bin\x64\Rgui.exe" LANGUAGE=en


Im using R Studio on a Mac and I couldn't find the Rconsole file. So I took a more brutal way and just deleted the unwanted language files from the R app. You just have to go to your Rapp in your application Folder, right click, show package content then /contents/Resources/. There are the language files e.g. English.lproj or in my case de.lproj wich I deleted. After restarting R, error messages appear in English.. Maybe thats helpful!

참고URL : https://stackoverflow.com/questions/13575180/how-to-change-language-settings-in-r

반응형