Install R packages in your home directory on the IU research supercomputers

On this page:


Overview

R packages are extensions to the R language. Developers commonly contribute packages to R package repositories, such as the Comprehensive R Archive Network (CRAN) repository.

On Indiana University's research supercomputers, many third-party R packages are installed to supplement commonly used R builds. If you have a unique need for a third-party R package that is not installed, you can install the package in your home directory. If you know several researchers are interested in using an R package that is not already installed, you can send a request to the Research Applications and Deep Learning (RADL) team to have it installed as a system-wide site package.

Set up your user environment

The IU research supercomputers use module-based environment management systems that provide a convenient method for dynamically customizing your software environment.

To install R packages on an IU research supercomputer, you must have R added to your user environment.

To add R to your user environment, load the r module; on the command line, enter:

module load r

Install R packages

  1. Create a subdirectory for the R packages you're installing (for example, ~/r-packages); on the command line, enter:
    mkdir ~/r-packages
  2. Create an R setting file (for example, .Renviron) in your home directory; on the command line, enter:
    touch ~/.Renviron
  3. Use your preferred editor to add this line to your R setting file (replace ~/r-packages with the path to the subdirectory you created for R packages):
    R_LIBS_USER="~/r-packages"
  4. Download the distribution archive from the source; for example, to download foo-1.0.3.tar.gz from the CRAN repository, on the command line, enter:
    wget https://cran.r-project.org/src/contrib/foo-1.0.3.tar.gz
  5. Install the package; on the command line, enter (replace foo-1.0.3.tar.gz with the distribution archive you downloaded):
    R CMD INSTALL foo-1.0.3.tar.gz

Use the following commands in the R terminal to search installed package directories and installed packages:

.libPaths()
library()
library(lib.loc='~/r-packages')

Get help

If you have questions about using statistical and mathematical software at Indiana University, contact the UITS Research Applications and Deep Learning team.

This is document bfrs in the Knowledge Base.
Last modified on 2023-12-13 17:26:16.