distance: Computes a multivariate distance between two vectors.

Description Usage Arguments Details Value Author(s) Examples

View source: R/distance.R

Description

Computes a multivariate distance (one of: "manhattan", "euclidean", "chi", and "hellinger") between two vectors of the same length. It is used internally by distanceMatrix and autoSum. This function has no buit-in error trapping procedures in order to speed up execution.

Usage

1
distance(x, y, method = "manhattan")

Arguments

x

numeric vector.

y

numeric vector of the same length as x.

method

character string naming a distance metric. Valid entries are: "manhattan", "euclidean", "chi", and "hellinger". Invalid entries will throw an error.

Details

Vectors x and y are not checked to speed-up execution time. Distances are computed as:

Note that zeroes are replaced by 0.00001 whem method equals "chi" or "hellinger".

Value

A number representing the distance between both vectors.

Author(s)

Blas Benito <blasbenito@gmail.com>

Examples

1
2
3
x <- runif(100)
y <- runif(100)
distance(x, y, method = "manhattan")

distantia documentation built on Oct. 30, 2019, 10:05 a.m.