본문 바로가기

Programing/R

R Console의 로케일 UTF-8로 설정하기.

R Console을 처음 실행하는데 다음과 같은 메세지가 나온다.


WARNING: You're using a non-UTF8 locale, therefore only ASCII characters will work.



로케일 설정이 UTF-8로 되어 있지 않다는 것인데, 그래서 ASCII 글자 밖에 쓸 수 없다는 것이다.


해결하는 방법은 로케일을 UTF-8로 설정하는 것.



Stackoverflow에 이미 해당 질문이 있다.


https://stackoverflow.com/questions/9689104/installing-r-on-mac-warning-messages-setting-lc-ctype-failed-using-c


1. 터미널에서 하는 방법

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


2. R console상에서 하는 방법

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


사실 둘은 동일하다.

R에서 호출하는 system 시스템콜은 터미널을 통해 하는 것과 동일하니까.


Description

system invokes the OS command specified by command.

Usage

system(command, intern = FALSE,
       ignore.stdout = FALSE, ignore.stderr = FALSE,
       wait = TRUE, input = NULL, show.output.on.console = TRUE,
       minimized = FALSE, invisible = TRUE, timeout = 0)

See Also

man system and man sh for how this is implemented on the OS in use.

https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html



Sell Also에도 적혀있지만 OS에서 사용하고 있는 system / sh 명령을 구현하고 있다고 한다.

man system으로 찾아보면 표준 C 라이브러리에서 제공하고 있는 시스템 콜임을 알 수 있다.