Installation

Beginner
Data Prep
A tutorial for installation of R and Rdistance
Author

Trent McDonald

Published

December 5, 2025

Modified

December 5, 2025

Follow these steps to get Rdistance up and running.


Install Base R

Rdistance is an R package. To install and use Rdistance, first install base R. If R is already installed, skip this.

Windows

Many R (and Rstudio) tutorials exist. The tutorial here has instructions for both Windows and Ubuntu.

Linux

A nice Linux-centric tutorial is here.


Install Compilation Tools

Rdistance depends on and imports a number of other packages. While Rdistance itself does not require compilation, some dependent packages require compilation. Compilation of these dependencies requires either Rtools (on Windows systems) or r-base-dev (on Linux systems). The number of dependencies is large, in part because Rdistance imports dplyr, so a fresh installation requires patience. If Rtools is already installed, skip this step.

Windows - Rtools

To install Rtools, download the correct Rtools installer for your version of R from here. When download completes, run the installer (double-click it) and accept all default options.

Linux - r-base-dev:

The equivalent of Rtools on Linux systems is r-base-dev. If R is already installed on a linux system, chances are that the machine’s repository lists are updated to include cloud.r-project.org/bin/linux/ubuntu (see ‘Installation’ section of here). Updated repository lists insure that the following apt get command functions correctly.

  1. Install the Linux equivalent of Rtools with the following command (in terminal):
sudo apt-get install r-base-dev
  1. Rdistance requires the units package, and the units package requires the udunits library. Install the udunits library on linux systems via:
sudo apt-get install libudunits2-dev

Install Rdistance

Once R is installed and running, install the current stable release or the development release with the following commands:

  1. Current release: Install the current release of directly from CRAN. In the R terminal, issue…
install.packages("Rdistance")
  1. Development version: Rdistance is under active development, and the ‘development’ version often contains patches between official releases. Inspect the commit messages on GitHub for a description of the patches. Install the development version using:
if( !require("devtools") ){
  install.packages("devtools")
}
devtools::install_github("tmcd82070/Rdistance")

Finished

When everything is installed, the library command shows that the units package is loaded and the Rdistance’s verson number1.

library(Rdistance)
Loading required package: units
udunits database from C:/Users/trent/AppData/Local/R/win-library/4.5/units/share/udunits/udunits2.xml
Rdistance (v4.1.1)

Footnotes

  1. Suppress these messages with suppressPackageStartupMessages(library(Rdistance)).↩︎