Installing R packages locally: Difference between revisions

From HPCwiki
Jump to navigation Jump to search
No edit summary
Line 32: Line 32:


== See also ==
== See also ==
* [[Control_R_environment_using_modules | Control R environment on the B4F Cluster using modules]]
* [[Control_R_environment_using_modules | Control R environment on the cluster using modules]]
* [[Parallel_R_code_on_SLURM | Using parallel R workloads under SLURM]]
* [[Parallel_R_code_on_SLURM | Using parallel R workloads under SLURM]]
* [[Bioinformatics_tips_tricks_workflows | Bioinformatics tips, tricks, and workflows]]
* [[Bioinformatics_tips_tricks_workflows | Bioinformatics tips, tricks, and workflows]]

Revision as of 15:56, 19 March 2019


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

Start up R:

<source lang='bash'>

 R                     # Invoke R

</source> 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. <source lang='rsplus'> install.packages("name-of-your-package",lib="~/R/library") </source>

See also

External links

source for material for this aricle

CRAN homepage

R article from Wikipedia