Rocky R package
About
The R modules on Rocky have many packages pre-loaded but not all of them. You are able to install your own packages locally in your home directory.
Installing
First we load the R module we want to use. For our example, we're going to use the R/4.2.2-foss-2022b module/version.
module load R/4.2.2-foss-2022b
Next we decide on a location for the R packages to be installed, make that directory, and then set the R_LIBS_USER environment variable to point to the new location. Here I have decided to use the name of the module/version as the directory name. If I choose to use a different R module/version later, I can choose a different package directory to use.
mkdir -p ~/R/4.2.2-foss-2022b export R_LIBS_USER="$HOME/R/4.2.2-foss-2022b"
Now I can start R and install the package. If you have not set a mirror, it will ask you to choose one.
R install.packages('adespatial')
Using
In our batch file for our job, we need to load the correct module for R and set the R_LIBS_USER environment variable so that it can find our installed packages.
spatial_test.sh
#!/bin/bash #SBATCH --job-name=SPATIAL_TEST #SBATCH --output=R_spatial_%j.out module load R/4.2.2-foss-2022b export R_LIBS_USER="$HOME/R/4.2.2-foss-2022b" Rscript spatial.R
You will run the job now just like any other job by using the sbatch command.
sbatch spatial_test.sh