Download and run the R installer (as administrator!) from https://cran.r-project.org/bin/windows/base.
(Optional) To build and compile packages, download and install the latest Rtools (as administrator!) from https://cran.r-project.org/bin/windows/Rtools/. Be sure to check the “add rtools to PATH” option during installation.
(Optional) Install GIS tools by downloading OSGeo4W from http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe and running the installer (select ‘Express Install’).
Download and run the R installer from https://cran.r-project.org/bin/macosx.
Install Xcode commandline tools from the terminal:
xcode-select --install
Install homebrew from the terminal (more info at https://brew.sh/):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
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
library(sf)
library(rgdal)
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.
Install R and its development libraries following instructions based on https://cran.r-project.org/bin/linux/ubuntu:
## 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- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | 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 https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"
## install R and its development libraries
sudo apt install r-base r-base-dev
Install java and configure R to use it:
sudo apt build-dep -y r-cran-rjava
sudo R CMD javareconf
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 \
tk-dev
For users who require multiple versions of R concurrently,
rig
(https://github.com/r-lib/rig) provides the simplest
mechanism for managing and running multiple installations.
Install rig
for your system following instructions
here: https://github.com/r-lib/rig#id-installation
Install the versions of R you need:
You can see the installed versions (and the default, starred) by
using rig list
.
Set the default version using the names from
rig list
:
Setup symlinks to allow easy launch of versioned R sessions:
E.g., to launch R 4.2 on macOS, use R-4.2-arm64
On macOS, restrict access to system package directories:
On macOS can also use the menu bar app (https://github.com/r-lib/rig#id-macos-menu-bar-app) to manage their R versions:
Be sure to open the Rig app preferences to allow launch at startup.
Recommended.
Download and run the installer for your operating system from https://posit.co/download/rstudio-desktop/.