Saturday, October 4, 2014

RStudio Error: package ‘forecast’ is not available (for R version 3.0.1)

When I tried to install 'forecast' package in RStudio, I got this error:

Warning in install.packages :
  package ‘forecast’ is not available (for R version 3.0.1)

Based on the search results, I need to install the latest version of R and restart RStudio for the changes to take effect.

Update R version using RGui (You can do this even in RStudio, but I felt it is slow) using this code:

if(!require(installr)) { 
+ install.packages("installr"); require(installr)} 

updateR() 

(Referene: http://www.r-statistics.com/2013/03/updating-r-from-r-on-windows-using-the-installr-package/)


R installer will be opened and you need go through the installation wizard. Then the packages will be installed in the new R version and will be updated.

No I can install forecast package in RStudio.

install.packages("forecast")
library(forecast)


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