Tools for Distance Metrics

Provides tools for constructing, manipulating and using distance metrics.

CRAN Status Build Status Build status codecov

The distances package provides tools for constructing, manipulating and using distance metrics in R. It calculates distances only as needed (unlike the standard dist function which derives the complete distance matrix when called). This saves memory and can increase speed. The package also includes functions for fast nearest and farthest neighbor searching.

How to install

distances is on CRAN and can be installed by running:


How to install development version

It is recommended to use the stable CRAN version, but the latest development version can be installed directly from Github using devtools:

if (!require("devtools")) install.packages("devtools")

The package contains compiled code, and you must have a development environment to install the development version. (Use devtools::has_devel() to check whether you do.) If no development environment exists, Windows users download and install Rtools and macOS users download and install Xcode.


distances 0.1.7

* Add support for logical

distances 0.1.6

  • Fixes incompatibility error with Sun make.

distances 0.1.5

  • Fixes compilation errors for C++ code on Solaris.

distances 0.1.4

  • Update R dependency

distances 0.1.3

  • Adds extract methods []
  • Updates maintainer information

distances 0.1.2

  • Fixes minor compilation errors on Solaris.

distances 0.1.1

  • Makes C-code POSIX compliant so package builds on Solaris.

distances 0.1.0

  • Initial release.

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.1.8 by ORPHANED, a year ago

Report a bug at

Browse source code at

Authors: Fredrik Savje [aut, cre]

Documentation:   PDF Manual  

GPL (>= 3) license

Imports stats

Suggests testthat

Imported by ORdensity, StempCens, liayson, optinterv.

Depended on by quickblock, quickmatch, scclust.

See at CRAN