Packages in R
Unfortunately, the ARC staff will no longer be able to maintain a complete set of R packages globally. Instead you will be able to install and maintain the packages you require for your project yourself.
Installing Packages
The process is fairly simple. From within R, the command looks like this:
install.packages(c(“package1″,”package2″,…,”packageN”))
In this form, R will prompt you for the repository mirror you want to use and will install each package in turn, including any dependencies. You will also be prompted for the location to store your installed package, which defaults to /home/<username>/R/<R version>/packagename.
Specifying CRAN Mirror
To prevent R from prompting for the CRAN mirror to use, you can specify one like this:
install.packages(c(“package1”),repos = “http://cran.case.edu”, )
The same format works for other repositories such as Bioconductor, R-forge, etc.
Installing From GitHub
To install packages from GitHub sites, you can do something like:
require(devtools)
install_github(“package1”)
Advanced Configurations
For more complex installations that require other specific libraries, you can specify configure.vars to specify include and library paths. For example, to install the rzmq package, you’d need the zeromq module loaded before starting R and you’d need to specify the include and library paths like this:
module load zeromq R/3.6.0
R
install.packages(c(‘rzmq’),repos = “http://cran.case.edu”, configure.vars=”INCLUDE_DIR=/packages/zeromq/3.2.5/include LIB_DIR=/packages/zeromq/3.2.5/lib”)
Finally, you can use package config for packages that want it, as well. This example installs the rjags package:
module load jags
export PKG_CONFIG_PATH=/packages/jags/4.3.0/lib/pkgconfig
pkg-config ––modversion jags
R
install.packages(c(‘rjags’),repos = “http://cran.case.edu”, configure.args=”––enable-rpath”)
As always, please don’t hesitate to contact us if you need further assistance with R package installation.