Skip to main content

R on macOS

The steps to install R depend on your Mac’s processor. To check which one you have, open the Apple menu and select About This Mac, or run uname -m in your terminal. If your Mac has an Apple chip (arm64), follow either the R installer or the Homebrew section, but not both. If it has an Intel processor (x86_64), follow the Intel section. Then install RStudio.

Arm-based Macs with the R installer

Download the latest .pkg file ending in arm64.pkg from R for macOS and open it. R requires macOS 14 (Sonoma) or later.

Install R packages with install.packages(). CRAN provides ready-made versions of the packages used in this course, including sf and terra, so you do not need to install GDAL or other libraries.

If R asks whether to install from source a package that needs compilation, answer No. R then installs the ready-made version, which may be slightly older.

To update R, download and install the latest .pkg file in the same way. R keeps a separate package library for each minor version, for example 4.5 and 4.6. After updating to a new minor version, reinstall the packages you need with install.packages().

Keep R up to date, because this installation does not update itself. CRAN stops updating the ready-made packages for older R versions, so you may get outdated packages, or R may try to compile newer ones, which can fail. If you already have R, check your version with R.version.string and compare it with the latest release on R for macOS.

Arm-based Macs with Homebrew

Homebrew is a command line package manager for macOS. If an R package fails to install, you are probably missing a software library, and Homebrew makes these easy to install (e.g., GDAL for the R package sf).

Before installing Homebrew, install the Apple Command Line Tools by running the following command in your terminal:

xcode-select --install

Then, follow the instructions on the Homebrew website to install Homebrew.

Install R with Homebrew:

brew install r

Install gdal and other dependencies required by R packages like terra and tidyverse:

brew install gdal udunits harfbuzz fribidi git libgit2 cmake

Install R packages with install.packages(). With Homebrew’s R, this compiles packages from source, so large packages can take several minutes.

To update R and your other Homebrew software, run:

brew update
brew upgrade

R keeps a separate package library for each minor version, for example 4.5 and 4.6. After updating to a new minor version, reinstall the packages you need with install.packages().

You can remove R from your system with brew remove r.

Intel-based Macs

Homebrew no longer supports Intel-based Macs, so use the R installer. Download the latest .pkg file ending in x86_64.pkg from R for macOS and open it. R requires macOS 11 (Big Sur) or later.

Install R packages with install.packages(). CRAN provides ready-made Intel versions of the packages used in this course, including sf and terra, so you do not need to install GDAL or other libraries.

If R asks whether to install from source a package that needs compilation, answer No. R then installs the ready-made version, which may be slightly older.

To update R, download and install the latest .pkg file in the same way. R keeps a separate package library for each minor version, for example 4.5 and 4.6. After updating to a new minor version, reinstall the packages you need with install.packages().

Keep R up to date, because this installation does not update itself. CRAN stops updating the ready-made packages for older R versions, so you may get outdated packages, or R may try to compile newer ones, which can fail. If you already have R, check your version with R.version.string and compare it with the latest release on R for macOS.

Install RStudio

Install R first, then download RStudio from the RStudio download page. The same download works on Arm-based and Intel-based Macs. The current release requires macOS 15 or later. For older macOS versions, find a compatible release in the macOS compatibility table.

If you use Homebrew, you can install RStudio from the terminal instead:

brew install --cask rstudio

brew upgrade then also updates RStudio.