Have a Question?
R Software on ARCC2
Configuring the R environment
Before using R on ARCC2, it is important to set the $R_LIBS_USER variable to allow R to find and/or install user-specific libraries. The most straightforward way to do this is to assign it in the .Renviron configuration file:
mkdir -p $HOME/path/to/your/R/libraries && echo R_LIBS_USER="$HOME/path/to/your/R/libraries " >> $HOME/.Renviron
One convenient option for the path /path/to/your/R/libraries is .Rlibraries, which will create a hidden directory by that name in $HOME. Once this is done, R can be accessed via ARCC2’s module system: to view all available versions1, enter the following in the ARCC2 command prompt:
module -r spider 'R$'
To load the desired version of R, simply type:
module load R/x.y.z
where x.y.z indicate version numbers. If these are not specified, the cluster will load the default version of R as indicated by the (D) tag in the output of the shell command module avail. With the module loaded, the command line interface to R can be started by typing R in the command prompt.
Using R on ARCC2
As mentioned above, R can be used interactively via the command line by typing R with the module loaded; this mode can be useful for downloading libraries or troubleshooting small pieces of code. For production code, jobs should be submitted to the scheduler via a submission script. As a minimal example:
#!/bin/bash
#SBATCH --nodes=1
#SBATCH --cpus-per-task=8
#SBATCH --job-name=YOUR-R-JOB-NAME
module purge
module load gcc
module load R/4.4.0
cd /PATH/TO/YOUR/WORKING/DIRECTORY
Rscript R-CODE-FILE.R
This script requests 8 CPU cores for the workflow specified in the file R-CODE-FILE.R. Note that requesting multiple cores does not automatically parallelize the R code; this must be done by the user within the code itself via a parallel library like doParallel. For users wanting a GUI, RStudio can be launched on ARCC2 using the OnDemand web interface. If the configuration steps described above are performed, RStudio will integrate with the libraries and packages already installed in the directory specified in the .Renviron file. New libraries downloaded in the RStudio instance will also be placed here for future use.
Troubleshooting
Most issues with R stem from an incorrectly configured environment. To confirm your environment is as you expect it to be, use the command .libPaths() from within an R instance to list the paths R uses to find libraries and packages; the path specified in the .Renviron file should be listed. Moreover, some R packages require libraries provided by the compiler: ensure you have the gcc module loaded in your interactive environment or batch script (this is done automatically for RStudio instances). If problems persist, please contact us at ARC_INFO.
- Versions earlier than 4.4 are currently unavailable due to security concerns. ↩︎