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...") |
|||
(One intermediate revision by the same user not shown) | |||
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. We are able to install our own packages locally in our home directory. | ||
= Installing = | = Installing = | ||
First we load the R module we want to use. For our example, we're going to use | First we load the R module we want to use. For our example, we're going to use R/4.2.2-foss-2022b. | ||
<pre> | <pre> | ||
Line 13: | Line 13: | ||
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 | 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. | ||
<pre> | <pre> | ||
Line 21: | Line 21: | ||
Now | Now we start R and install the package. If we have not set a mirror, it will ask for us to choose one. | ||
<pre> | <pre> | ||
R | R | ||
Line 30: | Line 30: | ||
= Using = | = Using = | ||
In our batch file for our job, we | 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. | ||
Line 47: | Line 47: | ||
We run the job just like any other Rocky job by using the sbatch command. | |||
<pre> | <pre> | ||
sbatch spatial_test.sh | sbatch spatial_test.sh | ||
</pre> | </pre> |
Latest revision as of 14:07, 29 February 2024
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