Installing R packages locally: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
== 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): | |||
<source lang='bash'> | |||
R_LIBS_USER="~/R/library" | |||
</source> | |||
This specifies a keyword (<code>R_LIBS_USER</code>) 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 | |||
<source lang='bash'> | |||
mkdir ~/R ~/R/library # Only need do this once | |||
</source> | |||
Set your R library path | |||
<source lang='bash'> | |||
echo 'R_LIBS_USER="~/R/library"' > $HOME/.Renviron | |||
</source> | |||
== Installing to a local library search location == | |||
Installation is dead easy. Start up R and tell R to fetch your package from CRAN, compile whatever needs compiling and set everything else up. | |||
Beware - each package will only work for the platform (i.e. Linux or Solaris) where you installed it. If you want a package on both Linux and Solaris, you'll need to install it in different directories for each system type. | |||
<source lang='bash'> | |||
R # Invoke R | |||
<source lang='bash'> | |||
> install.packages("name-of-your-package",lib="~/R/library") | |||
</source> | |||
<source lang='bash'> | <source lang='bash'> | ||
R_LIBS_USER="~/R/library" | R_LIBS_USER="~/R/library" |
Revision as of 21:21, 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): <source lang='bash'>
R_LIBS_USER="~/R/library"
</source>
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 <source lang='bash'>
mkdir ~/R ~/R/library # Only need do this once
</source> Set your R library path <source lang='bash'>
echo 'R_LIBS_USER="~/R/library"' > $HOME/.Renviron
</source>
Installing to a local library search location
Installation is dead easy. Start up R and tell R to fetch your package from CRAN, compile whatever needs compiling and set everything else up.
Beware - each package will only work for the platform (i.e. Linux or Solaris) where you installed it. If you want a package on both Linux and Solaris, you'll need to install it in different directories for each system type.
<source lang='bash'>
R # Invoke R
<source lang='bash'>
> install.packages("name-of-your-package",lib="~/R/library")
</source> <source lang='bash'> R_LIBS_USER="~/R/library" </source>