defaults write org.R-project.R force.LANG en_US.UTF-8
For someone runs R in a docker environment (under root), try to run R with below command,
LC_ALL=C.UTF-8 R
# instead of just `R`
Setting locales in terminal resolved the issue for me. Open the terminal and
Check if locale settings are missing
> locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
LC_MONETARY="C"
LC_NUMERIC="C"
LC_TIME="C"
LC_ALL=
Edit ~/.profile
or ~/.bashrc
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
Run . ~/.profile
or . ~/.bashrc
to read from the file.
Open a new terminal window and check that the locales are properly set
> locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
Just open the R(software) and copy and paste
system("defaults write org.R-project.R force.LANG en_US.UTF-8")
Hope this will work fine or use the other method
open(on mac): Utilities/Terminal copy and paste
defaults write org.R-project.R force.LANG en_US.UTF-8
and close both terminal and R
and reopen R
.
I found slightly different problem running R on through mac terminal, but connecting remotely to an Ubuntu server, which prevented me from successfully installing a library.
The solution I have was finding out what "LANG" variable is used in Ubuntu terminal
Ubuntu > echo $LANG
en_US.TUF-8
I got "en_US.TUF-8" reply from Ubuntu.
In R session, however, I got "UTF-8" as the default value and it complained that LC_TYPEC Setting LC_CTYPE failed, using "C"
R> Sys.getenv("LANG")
"UTF-8"
So, I tried to change this variable in R. It worked.
R> Sys.setenv(LANG="en_US.UTF-8")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With