Installing R

Traditional installation


  1. Download and run the R installer (as administrator!) from

  2. (Optional) To build and compile packages, download and install the latest Rtools (as administrator!) from Be sure to check the “add rtools to PATH” option during installation.

  3. (Optional) Install GIS tools by downloading OSGeo4W from and running the installer (select ‘Express Install’).


  1. Download and run the R installer from

  2. Install Xcode commandline tools from the terminal:

    xcode-select --install
  3. Install homebrew from the terminal (more info at

    /bin/bash -c "$(curl -fsSL"
  4. Install GDAL and other spatial packages:

    brew install pkg-config
    brew install gdal

    Then, install spatial R packages from source to pick up the new GDAL and PROJ libraries:

    ## (re)install spatial packages from source
    install.packages("sf", type = "source",
                     configure.args = "--with-proj-lib=$(brew --prefix)/lib/")
    install.packages("terra", type = "source")
    ## legacy spatial packages may still be required until fully retired Oct 2023
    install.packages("rgdal", type = "source",
                     configure.args = c("--with-proj-lib=$(brew --prefix)/lib/",
                                        "--with-proj-include=$(brew --prefix)/include/"))
    install.packages("rgeos", type = "source")
    ## confirm the GDAL, GEOS, PROJ versions being used
  5. Install GLPK (needed for full igraph functionality):

    brew install glpk

    Then, reinstall igraph from source so it is compiled with GLPK:

    install.packages("igraph", type = "source")


Install via apt or yum depending on your distribution. Instructions for Ubuntu 20.04 LTS are shown below.

  1. Install R and its development libraries following instructions based on

    ## update indices
    sudo apt update -qq
    ## install two helper packages we need
    sudo apt install --no-install-recommends software-properties-common dirmngr
    ## add the signing key (by Michael Rutter) for these repos
    ## To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 
    ## Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9
    wget -qO- | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
    ## add the R 4.0 repo from CRAN
    sudo add-apt-repository "deb $(lsb_release -cs)-cran40/"
    ## install R and its development libraries
    sudo apt install r-base r-base-dev
  2. Install java and configure R to use it:

    sudo apt build-dep -y r-cran-rjava
    sudo R CMD javareconf
  3. Install dependencies for spatial and other packages:

    sudo apt build-dep -y r-cran-tkrplot
    sudo apt-get install -y \
      curl \
      gdal-bin \
      git \
      libcairo2-dev \
      libcurl4-openssl-dev \
      libgdal-dev \
      libgeos-dev \
      libgit2-dev \
      libglpk-dev \
      libgmp-dev \
      libjq-dev \
      libmagick++-dev \
      libproj-dev \
      libprotobuf-dev \
      libprotoc-dev \
      libssh2-1-dev \
      libssl-dev \
      libudunits2-dev \
      libv8-dev \
      libxml2-dev \
      libxt-dev \
      pandoc \
      pandoc-citeproc \
      protobuf-compiler \
      python3-gdal \
      tcl-dev \

Alternate installation

For users who require multiple versions of R concurrently, rig ( provides the simplest mechanism for managing and running multiple installations.

  1. Install rig for your system following instructions here:

  2. Install the versions of R you need:

    rig add 4.3
    rig add 4.2
    rig add 4.1

    You can see the installed versions (and the default, starred) by using rig list.

    Set the default version using the names from rig list:

    rig default 4.3.1
  3. Setup symlinks to allow easy launch of versioned R sessions:

    rig system make-links

    E.g., to launch R 4.2 on macOS, use R-4.2-arm64

  4. On macOS, restrict access to system package directories:

    rig system fix-permissions
  5. On macOS can also use the menu bar app ( to manage their R versions:

    open -a Rig

    Be sure to open the Rig app preferences to allow launch at startup.

Launching Rstudio using a specific version of R

## e.g., on macOS:
rig rstudio 4.2-arm64

## e.g., for a project using renv on ubuntu:
cd ~/path/to/project
rig rstudio renv.lock

Installing Rstudio


Download and run the installer for your operating system from