Load and run R

  • Practice using the documentation of your HPC cluster

  • Load an R module

  • Start the R interpreter

  • Run an R script

  • Download and extract the exercise files

  • (optional) Find the different R modules

  • (optional) See the list of installed R packages

Introduction

You want to run R on an HPC cluster. For this, you’ll need to read the documentation of your HPC cluster.

In this session, we will use the documentation of your HPC cluster to start R.

Warning

Only do lightweight things!

We are still on the login node, which is shared with many other users. This means, that if we do heavy calculations, all the other users are affected.

How to do heavy calculations will be shown in this course later.

Exercises

HPC cluster name

Main breakout room

COSMOS

Room 1

Dardel

Room 2

Kebnekaise

Room 3

Rackham

Room 4

Tetralith

Room 5

Exercise 1: start the R interpreter

  • Find the documentation of your HPC cluster

  • Within the documentation of your HPC cluster, search for the documentation about R

  • From the terminal, load the module(s) for R, of the recommend version as shown below

HPC center

R version

COSMOS

4.2.1

Dardel

4.1.1

Kebnekaise

4.1.2

Rackham

4.1.1

Tetralith

4.2.2

  • From the terminal, start the R interpreter

  • From the R interpreter, run the R code message("Hello") to verify if this makes the R interpreter show the text ‘Hello’

  • From the R interpreter, run the R code quit() to quit the R interpreter and go back to the terminal

Exercise 2: run an R script

To run an R script, we’ll download one, after which we’ll run it:

  • From the terminal, run wget https://raw.githubusercontent.com/UPPMAX/R-python-julia-HPC/main/exercises/r/hello.R

  • From the terminal, run Rscript hello.R

Exercise 3: download and extract the tarball with exercises

See here how to download and extract the tarball with exercises.

Exercise X1: find and use installed R packages

  • From the R interpreter, check which packages are installed, using installed.packages()

  • From the R interpreter, load the parallel package, using library(parallel)

Exercise X2: search for other R versions

Use the module system to find which versions of R are provided by your cluster’s module system.