When package XYZ is not available for a specific version of R

When you try to install a package in R and you get the following message:

Warning in install.packages :
  package XYZ is not available (for R version x.xx.x)

is normally down to:

  • CRAN mirror is out-of-date in which case you can change the repo by using:
install.packages("XYZ",repos = "http://cran.us.r-project.org/")
  • Package author have not created a binary package for the specific version of R.

If the latter, here they are a set of simple steps to compile an R package from source.

  1. Go to package’s site, e.g. ggplot2
  2. Download the package source for your OS. For MacOS would be ggplot2_0.9.3.1.tgz
  3. Open an R session and type & run the following command:
install.packages("/path/to/file/packageName.tgz",repos = NULL, type="source")

and Voila! your package is now available for your version of R.

Note: If package has dependencies you may try to install them using the standard install.packages() and if they are not available then do the above steps.

blog comments powered by Disqus