Skip to content
System Status: All systems are operational • Services are available and operational.
Click for detailed status

R

R is a programming language for statistical computing and data visualization. It has been adopted in the fields of data mining, bioinformatics and data analysis.

R on Euler

Version Module Command
4.5.1 module load stack/2024-06 r/4.5.1
4.4.0 module load stack/2024-06 r/4.4.0
4.3.2 module load stack/2024-06 r/4.3.2

Package installation

To install new packages, run:

install.packages("<package_name>")

This will display a warning and will ask "Would you like to use a personal library instead? (y/n)", which you want. This installs packages into $HOME/R.

To display installed packages, run:

installed.packages()

Packages that require additional modules to be loaded for dependency libraries

Package Module Command
XML module load stack/2024-06 r/4.5.1 libxml2/2.10.3-xbqziof libiconv/1.17-uiaqkl2
terra, raster module load stack/2024-06 r/4.5.1 cmake/3.27.7 udunits/2.2.28 openssl/3.1.3-zhfub4o gdal/3.7.3 geos/3.13.1 proj/9.2.1 sqlite/3.43.2 abseil-cpp/20230802.1
packages that require zlib module load stack/2024-06 r/4.5.1 zlib-ng/2.1.4-xgiegbt

Known issue with terra and unit installation failing

If the installation for terra or unit are failing, then check the verison of the Rcpp package inside R with the command "packageVersion('Rcpp')". Newer versions of terra or unit require verison >=1.1.0. If the centrally provided Rcpp version is older, then please install a newer version of Rcpp first with the command "install.packages('Rcpp')". Afterwards, terra and unit should install fine.

Interactive session

Execute:

module load stack/2024-06 r/4.3.2

to make R available in your command line. Then:

R

launches an interactive session. You should see:

>

and you can try a simple command:

print("Hello, World!")

which should print:

[1] "Hello, World!"

Example program

Create a file hello.r, with the content:

print("Hello, World!")

Bring R and Rscript to your command line and run the program

module load stack/2024-06 r/4.4.0
Rscript hello.r

You should see

[1] "Hello, World!"

Compute-Intensive jobs

Compute-Intensive jobs must be submitted to the batch system (Slurm).

sbatch [sbatch options] "R --vanilla --no-echo < input_file.R > output_file"

They can be parallelized with a variety of packages. Here's a good overview on the topic: https://cran.r-project.org/web/views/HighPerformanceComputing.html