Setup and installation of R for the "R in an HPC environment" course

Setup and installation of R for the "Using R in an HPC environment" course

The purpuse of this documentation is mainly for setting up R, RStudio, and some R packages on your computer in preparation for the "R in an HPC environment" course that is given at HPC2N on 14-15 December 2022.

Before the course, please

  1. Install R, if you do not already have it installed. There are instructions below for various operating systems.
  2. Install RStudio, if you do not already have it installed. Again, there are instructions below.
  3. There is a list of R packages needed for the course. Please install them. Instructions for installing R packages in general is under each section for the specific operating system and the list of R packages needed is listed at the bottom of this page.

NOTE: These instructions assume that you have admin rights/root permission to the computer you are using. If you have permission problems installing R, RStudio, or any Rpackages, please look at this FAQ.

 
R is a free software environment for statistical computing and graphics. It compiles and runs on a wide variety of UNIX platforms, Windows and MacOS.
 

Windows

R

  1. Pick "R for Windows" from the nearest download mirror: UmU | Pick different mirror
  2. Choose the precompiled binary for the base distribution (the "install R for the first time" link)
  3. Download and install the .exe file (R-4.2.1-win.exe for the newest)
  4. For an older version, go here. The 3.6.2 version is guaranteed to work with the packages for this course.

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the Windows .exe file to download and install, following the instructions of the installer

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start the "R" program
  3. In the top menu of the window that opens, click “Packages”,then click “Install package(s)”.
  4. Choose a mirror that is close to your geographical location. There should be one for "ACC, Umeå University"
  5. Choose the package you wish to install. You can hold down the CTRL key to highlight and pick multiple packages.
  6. Click "OK"
  7. When your window prompt returns to a ">" the package has finished downloading and installing.

Only do the above once per package.

The R package knor (now knorR/clusternor)

This package has a prerequisite of Rcpp and a suggestion to also install testthat. So, install like for the other packages, but first install the prerequisites.

So install all these:

  • Rcpp
  • testthat
  • clusternor

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

macOS

R

  1. Pick "Download R for (Mac) OS X" from the nearest download mirror: UmU | Pick different mirror
  2. Choose the latest binary for the base distribution. Note that you may need to install XQuartz if not already installed, if you need to use X11.
  3. Download and install the .pkg file (R-4.2.1.pkg) by double-clicking on it.

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the macOS 10.15+ .dmg file to download. 
  3. When it has downloaded, double-click it to open, and then drag and drop it to your applications folder.

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

On macOS install.packages works as it does on other Unix-alike systems, but there is an additional type mac.binary (available for the CRAN distribution but not when compiling R from source) which can be passed to install.packages in order to download and install binary packages from a suitable repository. These binary package files for macOS have the extension ‘.tgz’. The R.APP GUI provides menus for installation of either binary or source packages, from CRAN or local files.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start Spotlight to find and start the "R" ("R64" if you have) program
  3. Wait for R to start. Now, in the top menu, click “Packages & Data”, then click “Package Installer”.
  4. Click "Get List". The first time it will ask you to choose a mirror. Pick one that is close to your geographical location. There should be one for "ACC, Umeå University". Pick that if you are in Sweden. You can set it as default to avoid being asked every time.
  5. In the pop-up window, make sure "Install Dependencies" is checked. Click "Update All" and "OK".
  6. Choose the package you wish to install from the list. You can search for it as well. Again, make sure "Install Dependencies" is checked.
  7. Click "Install Selected".
  8. When your window prompt returns to a ">" the package has finished downloading and installing.

Only do the above once per package.

Another, faster method of installing packages is the following, though it requires that you know the name of the package:

  1. Start the "R" program
  2. Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
  3. If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
  4. When your window prompt returns to a ">" the package has finished downloading and installing.

The R package knor (now knorR/clusternor)

This package has a prerequisite of Rcpp and a suggestion to also install testthat. So, install like for the other packages, but first install the prerequisites.

So install all these:

  • Rcpp
  • testthat
  • clusternor

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

Linux

There are detailed instructions for installation on Ubuntu 16.04, 18.04, 19.10, 20.04, 20.10, and 22.04 on a sharepoint document

R

You can either download precompiled binaries or compile from source. Links can be found from the The Comprehensive R Archive Network

  1. Linux Ubuntu
    1. sudo apt-get update
    2. sudo apt-get install r-base
  2. Other Linux distro
    1. Pick "Download R for Linux" from the nearest download mirror: UmU | Pick different mirror
    2. Choose a suitable distro
    3. Look at the "README" file in the directory to see how easiest to install R and the distributed packages.

RStudio

The base version of RStudio is free. It should suffice for the purposes of the course.

  1. Go to the download page for RStudio and pick the "Free" version
  2. Scroll down a little and pick the Linux binary that fits your distro. Download the file and install it. On Ubuntu, this is done with
    sudo dpkg -i <file>
    1. RStudio depends on a package that you may have to install, namely
      1. libclang-dev
    2. You can install it on Ubuntu with
      sudo apt-get install libclang-dev

R packages - installing

You will find a list of R packages here. The link goes to the mirror located in Umeå, but you can find other mirrors from this page.

You can see which packages are already installed by starting R and giving the command

installed.packages()

NOTE: The list of packages needed for the course is here.

There are several procedure for installing R packages, but the simplest is to do it through R:

  1. Find the name of the package you want, for example from the list of R packages
  2. Start the "R" program
  3. Type “install.packages(“RPACKAGE”)”, where RPACKAGE should be changed to the name of the specific package in question. Then press the Enter/Return key.
  4. If you have not installed other packages during this session, you will be prompted to choose a mirror to download from.
  5. When your window prompt returns to a ">" the package has finished downloading and installing.

This should be done only once for each package.

The R package knor (now knorR/clusternor)

This package has a prerequisite of Rcpp and a suggestion to also install testthat. So, install like for the other packages, but first install the prerequisites.

So install all these:

  • Rcpp
  • testthat
  • clusternor

In addition, it is recommended install the following system packages for best performance (but not necessary for the course):

build-essential libnuma-dbg libnuma-dev libnuma1

Note that there is a detailed instruction for installing the needed R packages if you are running Linux Ubuntu. It can be found here: installation on Ubuntu 16.04, 18.04, 19.10, 20.04, 20.10, and 22.04 on a sharepoint document.

R packages - loading into R

  1. Start the "R" program if it is not already running
  2. Type “library(RPACKAGE)”, where RPACKAGE should be changed to the name of the specific R package in question. Then press the Enter/Return key.
  3. The package should now be loaded and available.

List of R packages to install

This is the list of packages that we will use for the course. Some will probably only be used on Kebnekaise, but please install them on your own computer as well, before the beginning of the course.

There are detailed instructions for installation on Ubuntu 16.04, 18.04, 19.10, 20.04, 20.10, and 22.04 on a sharepoint document

Local machine

  • parallel (should be part of the base-R and thus installed with R)
  • Rmpi
  • foreach
  • doparallel
  • cluster
  • knor (now called clusternor)
  • boot

The R package knor (now knorR/clusternor)

This package has a prerequisite of Rcpp and a suggestion to also install testthat. So, install like for the other packages, but first install the prerequisites.

So install all these:

  • Rcpp
  • testthat
  • clusternor

For more information on this package, look at the GitHub page for knorR.

Kebnekaise

Most of the above packages are available as extensions to the R modules. This is how to load them (recommended version: R/4.0.4):

module load GCC/10.2.0  OpenMPI/4.0.5 R/4.0.4

or (with CUDA):

module load GCC/10.2.0  CUDA/11.1.1  OpenMPI/4.0.5 R/4.0.4

One of the modules is not available and needs to be installed

  • knor (now called clusternor)
Updated: 2024-04-17, 14:47