Submitting An R Job

To provide a tutorial, we will work with two files, my_rscript.R is a dummy R script that has a function to run.  The second file, run_rscript.sh shows you how to run an R job in SLURM.

Create the two files below:
my_rscript.R

sayHello <- function(){
   print('hello')
}

sayHello()

Both files need to be in the same directory, and the job is submitted via sbatch run_rscript.sh

run_rscript.sh

#!/bin/bash
#SBATCH --job-name=rscript
#SBATCH --time=0:0:10
#SBATCH --partition=debug
#SBATCH --nodes=1
#SBATCH --ntasks=1
#
#---------------------------------------------------------------------
# SLURM job script to run serial R
#---------------------------------------------------------------------
 
ml R
ml # confirm modules used
Rscript my_rscript.R