R#
R is a programming language and environment designed to work in the field of statistics.
Use R in TeideHPC#
Once connected to the login nodes, to see the available R versions, we use the modules tool:
module ava R
---------------------------------------------- /opt/envhpc/modulefiles/.rhel6 ----------------------------------------------
R/3.4.4/gcc R/3.6.1/gcc R/4.0.3/gcc R/4.1.1/gcc
To load any of the versions, we may need to load a module beforehand:
module load R/4.1.1/gcc
R/4.1.1/gcc(10):ERROR:151: Module 'R/4.1.1/gcc' depends on one of the module(s) 'gcc/10.2.0'
R/4.1.1/gcc(10):ERROR:102: Tcl command execution failed: prereq gcc/10.2.0
Therefore, we load the necessary modules, in the corresponding order:
module load gcc/10.2.0 R/4.1.1/gcc
module list
Currently Loaded Modulefiles:
1) openssl/1.1.1k/gcc 2) python/3.8.11/gcc 3) gcc/10.2.0 4) R/4.1.1/gcc
Now we can start using R:
R
R version 4.1.1 (2021-08-10) -- "Kick Things"
Copyright (C) 2021 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
>
Install R packages in /data#
By default, R will install packages in the user's /home
partition. This storage is limited in size, so we should configure the environments and install software in the /data
partition. To do this, we need to set an environment variable:
This way, R will use this path as the default library instead of the user's /home. When using R functions like install.packages()
and library()
, packages will be installed to the path defined in the R_LIBS_USER
variable. If you want to avoid having to set this variable every time you connect, you can add that line to the end of your ~/.bashrc
file, so it will be permanent.
Running an R script in Slurm#
To use an R script in Slurm, we have to run it as follows: