Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of warning messages after installing R? [duplicate]

Tags:

The following output can be obtained after installation of R by homebrew and without in my OSX:

During startup - Warning messages: 1: Setting LC_CTYPE failed, using "C" 2: Setting LC_COLLATE failed, using "C" 3: Setting LC_TIME failed, using "C" 4: Setting LC_MESSAGES failed, using "C" 5: Setting LC_MONETARY failed, using "C"         # this line is not occurring in OSX 10.10.1 Yosemite but other four are. 

I found an existing question but the solution does not work for me. I do this

  1. Open Terminal
  2. Write or paste in: defaults write org.R-project.R force.LANG en_US.UTF-8
  3. Close Terminal
  4. Start R

and the warning messages are still shown. I guess this works when installing R using the package from the R project page.

How to get rid of these warning messages after installation of R in OSX?

like image 497
Jan Deinhard Avatar asked Dec 04 '14 16:12

Jan Deinhard


1 Answers

Problem: Locale variables indicating what encoding to use are not set. To see the issue, in Terminal, type locale, and you likely get something like

LANG= LC_COLLATE= LC_CTYPE= LC_MESSAGES= LC_MONETARY= LC_NUMERIC="en_US.UTF-8" LC_TIME= LC_ALL= 

LC_NUMERIC may or may not be set, but given your errors, the rest are either not set or set to something R can't use. If those variables are empty, R is going to complain. To fix the problem:

Option 1: Terminal Preferences Go to Terminal's Preferences. Under the "Advanced" tab, make sure "Text Encoding" is set to "Unicode (UTF-8)" (or whatever you need). Make sure the checkbox underneath for "Set locale environment variables on startup" is checked. Unchecking it tends to leave locale variables unset or as "C", unless you've changed .bash_profile, .bashrc, or .profile (depending on your system). That may be enough to fix your problem. If not:

Option 2: Set from R To set them from inside of R, type

R> Sys.setenv(LANG="en_US.UTF-8") R> Sys.setenv(LC_ALL="en_US.UTF-8") 

...which should set all of the variables R is complaining about.

Option 3: Set from Terminal To set them from Terminal, type

export LANG=en_US.UTF-8 export LC_ALL=en_US.UTF-8 

...which should set the rest of the variables R is complaining about.

Check: In Terminal, type locale again. You should get

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" 

Restart R, and you should be set.

like image 77
alistaire Avatar answered Sep 18 '22 04:09

alistaire