R Computing

R Language

R is a programming language and environment commonly used in statistical computing, data analytics and scientific research. It is one of the most popular languages used by statisticians, data analysts, researchers and marketers to retrieve, clean, analyze, visualize and present data.

Slurm script

#!/bin/bash
#SBATCH --job-name=Rmpi_hello
#SBATCH --output=slurm.out
#SBATCH --error=slurm.err
#SBATCH --partition=CUIQue
#SBATCH --nodes=2
#SBATCH --ntasks-per-node=1

module load R/4.1.1

mpiexec -n ${SLURM_NTASKS} Rscript hello.R

 

The Code hello.R

library(Rmpi)
mpi.spawn.Rslaves(needlog = FALSE)

mpi.bcast.cmd( id <- mpi.comm.rank() )
mpi.bcast.cmd( np <- mpi.comm.size() )
mpi.bcast.cmd( host <- mpi.get.processor.name() )
result <- mpi.remote.exec(paste("I am", id, "of", np, "running on", host))

print(unlist(result))

mpi.close.Rslaves(dellog = FALSE)
mpi.exit()

 

Submit the job to the scheduler as

sbatch YourRScript.slurm

For managing your “job” , refer to this guide.

For more on R Language, refer to their official documentation
https://www.r-project.org/