Summary

You can find the module to be able to run R:

module spider R

You can load the module to be able to run R:

module load GCC/11.2.0 OpenMPI/4.1.1 R/4.1.2
module load GCC/11.3.0 OpenMPI/4.1.4 R/4.2.1
module load R/4.1.1

You can run the R interpreter

R

You can run the R command to get the list of installed R packages

installed.packages()

You can run an R script from the command-line

Rscript my_script.R

You can find out if an R package is already installed

installed.packages()
library(my_package)

You can load the pre-installed R packages

module load R_packages/4.1.1

You can install an R package from CRAN

install.packages("my_package", repos = "my_repo")

You can install an R package from GitHub

devtools::install_github("developer_name/package_name")

You can manually download and install an R package

echo R_LIBS_USER="$HOME/R-packages-%V" > ~/.Renviron
  • UPPMAX-only: I can manually download and install an R package on Bianca

rsync -Pa R ~/

You can use renv to create, activate, use and deactivate a virtual environment

renv::init()
renv::snapshot()
renv::restore()
  • UPPMAX-only: I can use conda to create, activate, use and deactivate a virtual environment

conda env create -f r_env.yaml
source activate r_env
deactivate

You can submit a job to the scheduler to run an R script with regular code

sbatch my_batch_script.sh
#!/bin/bash
#SBATCH -A my_account
#SBATCH -t 00:10:00
module load R
Rscript my_script.R

You can submit a job to the scheduler to run an R script that uses parallel code

#!/bin/bash
#SBATCH -A my_account
#SBATCH -t 00:10:00
#SBATCH -N 1
#SBATCH -c 4
R -q --slave -f my_parallel_script.R

You can submit a job to the scheduler to run an R script that uses a GPU

#SBATCH --gres=gpu:x
#SBATCH -C v100
#SBATCH -p gpua100
#SBATCH --gres=gpu:1

You can find and load the R machine learning modules

module load R/4.1.1 R_packages/4.1.1
module load GCC/11.2.0 OpenMPI/4.1.1 R/4.1.2 R-bundle-Bioconductor/3.14-R-4.1.2
module load GCC/11.3.0 OpenMPI/4.1.4 R/4.2.1 R-bundle-Bioconductor/3.15-R-4.2.1
module load GCC/11.3.0 OpenMPI/4.1.4 R/4.2.1 CUDA/12.1.1

You can submit a job to the scheduler to run an R script that uses machine learning

sbatch my_ml_script.sh

You can start an interactive session

interactive -A my_project_code
salloc -A my_project_code

You can verify I am on the login node yes/no

srun hostname

You can start an interactive session with multiple cores

interactive -n 4 -A my_project_code
salloc -n 4 -A my_project_code

You can verify my interactive session uses multiple cores

srun hostname

You can start RStudio

module load R/4.1.1 RStudio/2023.12.1-402
rstudio