46

I'm trying to install a package into R, something I swore on my blood never to do, yet here I am.

The command supposedly goes:

install.packages('NCStats',,'http://www.rforge.net/')` 

while I am enjoying the healthy dose of:

Warning: dependencies 'nortest', 'plotrix', 'sciplot', 'car', 'gplots', 'gdata', 'Hmisc', 'TeachingDemos' are not available  
trying URL 'http://www.rforge.net/bin/macosx/leopard/contrib/2.11/NCStats_0.1-4.tgz'  
Content type 'application/x-gzip' length 237120 bytes (231 Kb)  
opened URL  
=================================================="  
downloaded 231 Kb  
tar: Failed to set default locale  
The downloaded packages are in
    /var/folders/Qj/Qjps7xnxFcWdSHsJY3lo+k+++TI/-Tmp-//RtmpzNO8MM/downloaded_packages`

Le-sigh. Anybody know how I can tell tar what locale I'm in, not that I understand why it needs that or why it can't just know it already?

I'm running OSX 10.6.4 and R 2.11.1 GUI 1.34 Leopard build 64-bit (5589).

gakera
  • 3,589
  • 4
  • 30
  • 36
  • 2
    For starters, how about trying to satisfy the noted *Depends* you do not seem to have on your box? – Dirk Eddelbuettel Oct 11 '10 at 15:57
  • 1
    what do you get returned from `Sys.getlocale()` ? – Joris Meys Oct 11 '10 at 16:51
  • Ack, too bad Joris, I forgot to check that before I tried the answer below, but I suspect it was Icelandic or something, since that's what my system preferences are. Dirk, since this package doesn't work after that command, it's unusable, I'm not going to navigate some labyrinth of dependancies. – gakera Oct 11 '10 at 20:33
  • Why would you swear you never would install a package? – jzadra Jun 04 '20 at 22:46
  • 10 years ago it was a pain (as you can see). Now it's much nicer, and my blood has boiled off. – gakera Dec 14 '21 at 15:48

4 Answers4

83

Step 1 (In R Console)

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

Step 2: Restart R

Source: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html#Internationalization-of-the-R_002eapp

Brandon Bertelsen
  • 43,807
  • 34
  • 160
  • 255
  • 12
    Thank you, that works. To be 100% clear, that command is copy pasted into the Terminal, not the R console, and then the R console needs to be restarted. – gakera Oct 11 '10 at 20:28
  • 1
    Worked for problems with the rJava package too. – The Unfun Cat Sep 21 '12 at 09:32
  • 3
    This didn't work for me on OSX 10.9.5. I am actually on a German computer and so `echo $LANG` returns **de_DE.UTF-8**. I tried this in place of _en-US.UTF-8_ and also your answer exactly as-is - neither had any effect. – n1k31t4 Oct 20 '15 at 10:40
  • 1
    Please edit this answer to tell people to quit and restart R. – Jubei Mar 30 '17 at 16:55
23

Use this command in the R console:

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

Remember to quit and start again R.

IUF
  • 313
  • 3
  • 10
8

refer: https://github.com/nerves-project/nerves/issues/376#issuecomment-456939623

If you don't want to permanently set env. variable. do:

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

No need to restart the system.

Bharat Pahalwani
  • 1,404
  • 3
  • 25
  • 40
0
  • Better Close the entire R studio and Reopen it again will fix that error tar: Failed to set default locale