Installing R packages locally: Difference between revisions
Jump to navigation
Jump to search
| Line 35: | Line 35: | ||
== External links == | == External links == | ||
[http://csg.sph.umich.edu/docs/R/localpackages.html source for material for this aricle] | [http://csg.sph.umich.edu/docs/R/localpackages.html source for material for this aricle] | ||
[http://cran-mirror.cs.uu.nl CRAN homepage] | [http://cran-mirror.cs.uu.nl CRAN homepage] | ||
[http://en.wikipedia.org/wiki/R_(programming_language) R article from Wikipedia] | [http://en.wikipedia.org/wiki/R_(programming_language) R article from Wikipedia] | ||
Revision as of 22:30, 26 November 2013
Specifying a local library search location
Specify a local library search location.
You can use several library trees of add-on packages. The easiest way to tell R to use these via a 'dotfile' by creating the following file '$HOME/.Renviron' (watch the quotes and ~ character):
R_LIBS_USER="~/R/library"
This specifies a keyword (R_LIBS_USER) which points to a colon-separated list of directories at which R library trees are rooted. You do not have to specify the default tree for R packages.
If necessary, create a place for your R libraries
mkdir ~/R ~/R/library # Only need do this once
Set your R library path
echo 'R_LIBS_USER="~/R/library"' > $HOME/.Renviron
Installing to a local library search location
Start up R:
R # Invoke R
Then, from the R environment, install the packages you require while pointing at the root R-package directory of choice. This example will install from CRAN.
install.packages("name-of-your-package",lib="~/R/library")