Exercises

Load and run

Try yourself to load R, start it, check libraries, load a library, quit R

1) Load R version 4.1.1
2) Start R. Check which libraries are installed. Load one of them.
3) Quit R

Remember to check if a module you are loading has prerequisites, and load those first if it does. In this case it depends on whether you do the exercises on Kebnekaise or Rackham.

Load R and run a short R script from the command line

  1. Load R version 4.1.x (if you have not done so already)

  2. Run the small R script called hello.R, using Rscript

Remember to check if a module you are loading has prerequisites, and load those first if it does. In this case it depends on whether you do the exercises on Kebnekaise or Rackham. Remember, Kebnekaise has 4.1.2 and Rackham has 4.1.1.

“hello.R” (it can also be found under “R” in the “Exercises” directory on the course GitHub repository (https://github.com/UPPMAX/R-python-julia-HPC).

message <-"Hello World!"
print(message)

Packages

Install a package with automatic download

1) First do the setup of .Renviron and create the directory for installing R packages. Remember to load any modules you need.

  1. Install a package from the command line. Suggestion: the package “anomalize”

  2. Install a package from inside R. Suggestion: the package “tidyr”

  3. Start R and see if the library can be loaded.

These are both on CRAN, and this way any dependencies will be installed as well.

Remember to pick a repo that is nearby, to install from: https://cran.r-project.org/mirrors.html

Batch mode

Serial batch script for R

Run the serial batch script shown in the session “Running R in batch mode”, but for the add2.R code (see the Exercise/R directory on GitHub). Remember the arguments.

Parallel job run

Try running the parallel example with “foreach” from the session “Running R in batch mode”.

R for ML

Run the ML examples shown in the session “ML with R”.