Difference between revisions of "Rocky R package"
(Created page with "= About = The R modules on Rocky have many packages pre-loaded but not all of them. If you find yourself needing one that isn't, you are able to install it 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. <pre> module load R/4.2.2-foss-2022b </pre> Next we decide on a location for the R packages to be installed, make that directory, and then set th...") |
|||
Line 1: | Line 1: | ||
= About = | = About = | ||
The R modules on Rocky have many packages pre-loaded but not all of them. | 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. | ||
Revision as of 20:12, 28 February 2024
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