Skip to content

Using R Packages

userz edited this page Aug 22, 2017 · 1 revision

This guide will show you how to setup your HPC account so that you can access the AidData REU R packages and also install and access your own R packages. Make sure the R module is loaded before attempting to run a job with R or open an R process to install packages.

  1. Log in to your HPC account
  2. Create / open a file called ".Renviron" >> nano ~/.Renviron
  3. Add the following to the file: R_LIBS="~/R_libs:/sciclone/aiddata10/REU/R_libs"

This tells any R process you start to look for packages in a folder called "R_libs" in your home directory (see below for details on installing packages to your home directory) and in the central AidData repository of R packages

You can now access any R packages available in the AidData central repository normally by using library(<package-name>) in R

The packages available from the AidData central repository can be seen using ls /sciclone/aiddata10/REU/R_libs/ while logged in to sciclone. Note: additional packages not listed here may have been installed globally on sciclone. Such packages may be documented as an issue with the "software request" label (eg: rgdal)


To install and use packages not available through the AidData central repository take the following steps:

  1. make a new folder called R_libs in your home directory >> mkdir ~/R_libs
  2. start a BASH shell by typing bash while logged into your HPC account
  3. start R by typing R
  4. install a package to your local R_libs folder >> install.packages(<package-name>, lib="~/R_libs")
  5. select a CRAN repo to download from

You can now access your local R package normally using library(<package-name>)