Rocky R package
About
The R modules on Rocky have many packages pre-loaded but not all of them. We are able to install our own packages locally in our home directory.
Installing
First we load the R module we want to use. For our example, we're going to use R/4.2.2-foss-2022b.
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 we use the name of the module as the package directory name since each version will need it's own packages installed separately.
mkdir -p ~/R/4.2.2-foss-2022b export R_LIBS_USER="$HOME/R/4.2.2-foss-2022b"
Now we start R and install the package. If we have not set a mirror, it will ask for us to choose one.
R install.packages('adespatial')
Using
In our batch file for our job, we load the R module and set the R_LIBS_USER environment variable so that our job 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
We run the job just like any other Rocky job by using the sbatch command.
sbatch spatial_test.sh