About R

R is a general purpose statistical computing package, and one of its appeals is the very large library of additional techniques that is available. RStudio is a separate program that provides an interactive development environment (IDE) for R is also available and that can be run from Open OnDemand. We also install a couple of collections of libraries and make those available as loadable modules for your convenience. See below for details; we put the section on installing libraries for yourself at the bottom.


The Tidyverse is very popular and with the dependencies it requires be installed adds up to several hundred R libraries (also called packages, which we will use interchangeably). For convenience, we install the Tidyverse packages and make those available via an Rtidyverse module on most systems, whether the version is that of the underlying R used; so Rtidyverse/4.0.3 is R 4.0.3 with Tidyverse.


We collected together a number of geospatial packages for R, several of which can be tricky to install if R is not installed in the default location (which our R is not). These are made available via the Rgeospatial module.

R with MPI

Getting R to work with MPI can also be tricky, so we install Rmpi and the related doMPI packages and make those available via the Rmpi module. Once again, the version is that of the underlying R, not of Rmpi. In our experience, very few people actually write MPI code in R, so Rmpi is typically used by some other package and not used directly. The most popular seems to be the doMPI package which parallels doParallel, so we also install doMPI with Rmpi.

Installing your own packages

R packages are installed once, and they are typically installed interactively from a login node. Since Open OnDemand has become available, many people are using a session within it to install packages. We do recommend that you not install packages from the RStudio application there. Installing from the command line from a login node is the preferred way to install packages.

The general procedure is to load the R module, then run R. From the R prompt, use

> install packages('package_name')

The first time you install a package, you will be asked if you want to install it to a personal library, and you do, so say ‘yes’. It will also offer to create one at ~/R/x86_64-pc-linux-gnu-library followed by the first two digits of the R version. Use that unless you know what you are doing.

In most cases, that will just work.

We have a repository for R packages here at UM, and if you put the following into your ~/.Rprofile file, you will not be asked to choose a repository each time.

# Set the R mirror to UMich
local({r <- getOption("repos")
       r["CRAN"] <- "http://repo.miserver.it.umich.edu/cran"