Monday, September 29, 2014

MAC OS X- installing package 'gdata' in RStudio (ERROR: tar: failed to set default locale)

These days I am working on R using RStudio and came with an interesting problem when I start to install 'gdata' package.

Error: tar: failed to set default locale

The 'gdata' package is required to use when you want to import excel files to your RStudio workspace.

I found that this is a problem with MAC OS. And you will face this issue if you try to install a new package (not only gdata).

So the solution is to change the settings. In the terminal, type:

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

This happens because of the internationalization of the R.app and you are using a non standard setup like different language. Thus, you will override the auto detection and set default setting.

Then you need to quit RStudio, for the changes to take effect and then open it. Restarting RStudio using RStudio commands won't work.

Type:
> install.packages("gdata")
> library("gdata", lib.loc="/Library/Frameworks/R.framework/Versions/3.0/Resources/library")

You can do this through the GUI as well.

Tool>Install Packages
Then from right bottom panel under libraries select gdata library.


Reference: http://cran.r-project.org/bin/macosx/RMacOSX-FAQ.html