1  Installing R and Spatial Packages

Authors

Alex Chubaty

Eliot McIntire

Published

June 10, 2024

To use SpaDES, a user must have R installed, plus some dependencies. Furthermore, it will be easier if the user also has Rtools installed. Finally, our group works with RStudio so many directions will rely on RStudio tools. Installing RStudio will make it easier for training and learning.

1.1 Install R

1.1.1 Windows

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

  2. Download and install the Rtools version that matches the installed R version. Be sure to check the “add Rtools to PATH” option during installation if necessary (Rtools v4.0).

1.1.2 macOS

  1. Download and run the R installer from https://cran.r-project.org/bin/macosx.

  2. Install Xcode commandline tools from the terminal:

xcode-select --install
  1. Install homebrew from the terminal (instructions at https://brew.sh/)

  2. Install GDAL and other spatial packages (instructions at https://www.alexchubaty.com/post/2020-01-08-using-latest-gdal-macos-redux/)

  3. Install OpenMP support for data.table:

brew update && brew install llvm
  1. Install GLPK (needed for full igraph functionality; used with SpaDES.core::moduleGraph):
brew install glpk

Then, in R, install igraph from source so it is compiled with GLPK:

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

1.1.3 Linux

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

  1. Install R and its development libraries:
sudo apt install r-base r-base-dev
  1. Install java and configure R to use it:
sudo apt build-dep -y r-cran-rjava
sudo R CMD javareconf
  1. Install dependencies for spatial and other packages:
sudo apt build-dep -y r-cran-tkrplot

sudo apt-get install -y \
ccache \
gdal-bin \
git \
libcairo2-dev \
libcurl4-gnutls-dev \
libgdal-dev \
libgeos-dev \
libgit2-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 \
python-gdal \
python3-gdal \
curl \
r-cran-littler

1.2 Troubleshooting

For Mac users, it may be helpful to use brew doctor:

brew doctor

If you are still not able with the above instructions, you may be able to follow these more in-depth instructions.

1.3 See also

Hands on programming with R