R on MeluXina
The MeluXina system environment provides the R programming language.
EasyBuild module description
R is a free software environment for statistical computing and graphics.
R usage
Interactive
Reserve an interactive session:
salloc -A COMPUTE_ACCOUNT -t 01:00:00 -q dev --res cpudev -p cpu -N 1
The example above will allocate one CPU node in interactive mode (dev QoS with cpudev reservation). Load the R (Will load default version if not specified) module as in below script.
module load R
#Get in R environment
R
Output
R version 4.0.5 (2021-03-31) -- "Shake and Throw"
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.
>
It is also possible to execute your R
script in interactive mode by using Rscript
command.
Rscript example.R
Script
# Sample script.
y=c(12,15,28,17,18)
x=c(22,39,50,25,18)
mean(y)
mean(x)
plot(x,y)
Batch
R can also be used in a batch job using Slurm. The script below executes a simple R HelloWorld test on one CPU node allocated for 5 minutes.
#!/bin/bash -l
#SBATCH -N 1
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=1
#SBATCH -p cpu
#SBATCH -q test
#SBATCH --time 00:05:00
#Load R module
module load R
#Check R version
R --version
#Execute R script
Rscript rscript.R