Big Data/Analytics Zone is brought to you in partnership with:

Jonathan Callahan received his Ph.D. in Physical Chemistry from the University of Washington in 1993. After two years as a post-doc in a magnetic resonance imaging laboratory, Jonathan joined NOAA's Pacific Marine Environmental Laboratory to work on analysis and visualization software for oceanographic climate and model data. Since 2007 Jonathan has worked as an independent consultant for NOAA, NASA and the US EPA. His areas of expertise include: data management; data visualization; statistical analysis using R; interface design; data mining; web services architecture. Jonathan writes occasional articles on data management at Working With Data. Jonathan is a DZone MVB and is not an employee of DZone and has posted 12 posts at DZone. You can read more from them at their website. View Full User Profile

Using R — Package Installation Problems

02.25.2013
| 1754 views |
  • submit to reddit

The post titled Installing Packages described the basics of package installation with R.  The process is wonderfully simple when everything goes well.  But it can be maddening when it does not.  Error messages give a hint as to what went wrong but do not necessarily tell you how to resolve the problem.  This post will collect some of the error messages we’ve encountered while installing R packages and describe the reasons for the error and the workarounds we’ve found.

1) Older version of R

Warning message:
In install.packages(c("sp")) : package ‘sp’ is not available

This is the message that you get when the CRAN package you’re interested in requires a more recent version of R than you have.  Remember, the default behavior ofinstall.packages() is to grab the latest version of a package.

In this case you have to poke around in the “Old sources” link on the CRAN page for that package and use trial-and-error to find an older version of the package that will work with your version of R.  You should start by determining what version of R you have:

12$R--versionRversion2.8.1(2008-12-22)

This version of R was released at the end of 2008 and any version of the “sp” package released in 2008 should work. At least some of the 2009 releases should also work. Perusing the sp archive, we might try installing version 0.9-37, the last of the 0.9-3x series which was released in May of 2009:

1234$wget http://cran.r-project.org/src/contrib/Archive/sp/sp_0.9-37.tar.gz$sudo CMD INSTALL sp_0.9-37.tar.gz...$# Success!

2) Unable to execute files in /tmp directory

ERROR: 'configure' exists but is not executable -- see the 'R Installation and Administration Manual'

By default, R uses the /tmp directory to install packages.  On security conscious machines, the /tmp directory is often marked as “noexec” in the /etc/fstab file.  This means that no file under /tmp can ever be executed.  Packages that require compilation or that have self-inflating data will fail with the error above.  One such package isRJSONIO.

The solution is to set the TMPDIR environment variable which R will use as the compilation directory. For csh shell:

12$mkdir~/tmp$setenv TMPDIR~/tmp

And for bash:

12$mkdir~/tmp$export TMPDIR=~/tmp

Other problems

Please leave comments describing other package installation problems and solutions you’ve encountered to help us build a more complete listing.

Published at DZone with permission of Jonathan Callahan, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)