Sunday, June 3, 2007

Install a R source package in local directory

If you don't have root access to your machine, it seems that it is not possible to install a package for R using install. Let's say you want to install some packages in $HOME/local/lib/R/library. Two things are necessary:
  1. Install the package with R at the correct location
  2. Tell R to look for the package at this location
The first is a simple matter of doing the following at the root of the package to install sources:

R CMD INSTALL -l $HOME/local/lib/R/library .

Then, you just have to launch R with the path set in R_LIBS:

R_LIBS=$HOME/local/lib/R/library/ R

You can then use library("name") to import the package from its name

1 comment:

John said...

Thanks man! This is exactly what I needed to know.