R on the clusters
R is provided via the DCSR software stack
To load R:
module load gcc r R # Then you can use R interactively > ...
While using R in batch mode, you have to use
Rscript to launch your script. Here is an example of sbatch script,
#!/bin/bash #SBATCH --time 00-00:20:00 #SBATCH --nodes 1 #SBATCH --ntasks 1 #SBATCH --cpus-per-task 1 #SBATCH --mem 4G module load gcc r Rscript my_r_script.R
Then, just submit the job to Slurm:
A number of core packages are installed centrally - you can see what is available by using the
library() function. Given the number of packages and multiple versions available other packages should be installed by the user.
Installing R packages is pretty straightforward thanks to install.packages() function. However, be careful since it might fill your home directory very quickly. For big packages with large amount of dependencies, like
adegenet for instance, you will probably reach the quota before the end of the installation. Here is a solution to mitigate that problem:
- Remove your current R library (or set up an alternate one as explained in the section Setting up an alternate personal library below):
rm -rf $HOME/R
- Create a new library in your scratch directory (obviously modify the path according to your situation):
mkdir -p /scratch/FAC/FBM/DEE/my_py/default/jdoe/R
cd $HOME ln -s /scratch/FAC/FBM/DEE/my_py/default/jdoe/R
- Install your R packages
Warning for Jura!!!
Please refer to the page dedicated to offline installation on Jura.
Setting up an alternate personal library
If you want to set up an alternate location where to install R packages, you can proceed as follows:
mkdir -p ~/R/my_personal_lib2 # If you already have a ~/.Renviron file, make a backup cp -iv ~/.Renviron ~/.Renviron_backup echo 'R_LIBS_USER=~/R/my_personal_lib2' > ~/.Renviron
Then relaunch R. Packages will then be installed under