Skip to content

R on Pelle

The R logo, from https://www.r-project.org/logo/

R is a programming language for statistical computing and data visualisation (from Wikipedia).

I need the Bianca pages!

Here we discuss:

flowchart TD

    subgraph r[R]
      r_interpreter[the R interpreter]
      r_packages[R packages]
      r_language[the R programming language]
      r_dev[R software development]
      rstudio[RStudio]

      interpreted_language[Interpreted]
      cran[CRAN]
    end

    subgraph uppmax_modules[UPPMAX modules]
      r_module[R]
      r_packages_module[R-bundle]
      rstudio_module[RStudio]
    end


    r_language --> |has| r_dev
    r_language --> |is| interpreted_language
    r_language --> |uses| r_packages
    interpreted_language --> |done by| r_interpreter
    r_packages --> |maintained by| cran
    r_dev --> |commonly done in| rstudio

    r_interpreter --> r_module
    r_packages --> r_packages_module
    rstudio --> rstudio_module

    r_packages_module --> |automatically loads corresponding version of| r_module

the R programming language

R is 'a programming language for statistical computing and data visualisation') and is of the most commonly used programming languages in data mining, analysis and visualisation.

R is an interpreted language; users can access it through the R interpreter.

R is a dynamically typed programming language with basic built-in data structures are (among others): vectors, arrays, lists, and data frames. and its supports both procedural programming and object-oriented programming.

R has many user-created R packages to augment the functions of the R language, most commonly hosted on CRAN. These packages offer statistical techniques, graphical devices, import/export, reporting (RMarkdown, knitr, Sweave), etc.

the R interpreter

The R interpreter is the program that reads R code and runs it. Commonly, 'the programming language R' and 'the R interpreter' are use as synonyms.

To load the latest version of the R interpreter, load the R module version 4.3.1 like this:

module load R/4.3.1
Do I really need to load an R module?

We strongly recommend loading an R module.

If you do not load an R module, you will be using the version of R used by the UPPMAX systems.

Sometimes that may work.

If not, load an R module.

Need a different version?

If you need a different R version, use the following command to see which versions of the R interpreter are installed on UPPMAX:

module spider R

Then start the R interpreter with:

R

R packages

R packages extend what R can do. The most common repository for R packages is CRAN. As these packages are so common, UPPMAX provides the CRAN packages in one module, called R-bundle-CRAN

To load the latest version of the pre-installed R packages, do:

module load R-bundle-CRAN

This will automatically load the corresponding version of the R interpreter (for version2024.11-foss-2024a it is R/4.4.2).

Need a different version?

If you need a different package version, use the following command to see which versions of the R packages are installed on UPPMAX:

module spider R-bundle-CRAN

R-bundle-Bioconductor

For Bio users R-bundle-Bioconductor/3.20-foss-2024a-R-4.4.2 is useful!

R software development

RStudio in action on Bianca using the remote desktop environment

RStudio in action on Bianca using the remote desktop environment

Software development is commonly done in a so-called Integrated Development Environment, abbreviated 'IDE.

RStudio is the most commonly used IDE for R software development. See the UPPMAX page about RStudio on Pelle on how to use.

How to install personal packages

First load both R-bundle-Bioconductor and R-bundle-CRAN/ to make sure that the package is not already installed!

To install personal packages in your own home directory you type

install.packages("package_name")

as usual. That will install all your packages under the path ~/R/[arch]/[version of R]/. Then you can load it by just doing library(package_name) or require(package_name) in the R environment.

You can also specify a specific folder for where to put your packages, with

install.packages("package_name", lib="~/some/path/under/your/home/directory/")

But to then be able to find the package inside the R environment you need to either export the R_LIBS_USER environment variable, or specify the flag lib.loc when calling require/library, e.g.

library(package_name, lib.loc='~/some/path/under/your/home/directory')

Notice that if you are planning on running R on different clusters then it is probably wisest to manually specify the installation directory, and to have separate directories for each cluster. This is because some of the clusters have different architectures, and this will render some packages unusable if you compile them on one system but try to run them on the other.

Technicalities

As of this writing, our most recent installations are

  • R/4.5.1
  • R-bundles compatible with R-4.4.2
  • RStudio/2025.09.0-387

If you need an older version, do module avail R or R-bundle or RStudio to see older versions as well.

Common errors

Here we will gather common errors.

Graphical device not supporting transparency

Error message

Warning message:
In plot.xy(xy, type, ...) :
   semi-transparency is not supported on this device: reported only once per page
null device

Solution

place the following in your ~/.Rprofile

setHook(packageEvent("grDevices", "onLoad"),
function(...) grDevices::X11.options(type='cairo'))
options(device='x11')