distance: Calculate dissimilarity/distance metrics

Description Usage Arguments Value Author(s) See Also Examples

View source: R/distance.R

Description

This function calculates a variety of dissimilarity or distance metrics. Although it duplicates the functionality of dist() and bcdist(), it is written in such a way that new metrics can easily be added. distance() was written for extensibility and understandability, and is not an efficient choice for use with large matrices.

Usage

1
distance(x, method = "euclidean", sprange=NULL, spweight=NULL)

Arguments

x

matrix or data frame with rows as samples and columns as variables (such as species). Distances will be calculated for each pair of rows.

method

Currently 7 dissimilarity metrics can be calculated: "euclidean", "bray-curtis", "manhattan", "mahalanobis", "jaccard", "difference", "sorensen", "gower", "modgower10" (modified Gower, base 10), "modgower2" (modified Gower, base 2). Partial matching will work for selecting a method.

sprange

Gower dissimilarities offer the option of dividing by the species range. If sprange=NULL no range is used. If sprange is a vector of length nrow(x) it is used for standardizing the dissimilarities.

spweight

Euclidean, Manhattan, and Gower dissimilarities allow weighting. If spweight=NULL, no weighting is used. If spweight="absence", then W=0 if both species are absent and 1 otherwise, thus deleting joint absences.

Value

Returns a lower-triangular distance matrix as an object of class "dist".

Author(s)

Sarah Goslee <Sarah.Goslee@ars.usda.gov>

See Also

dist

Examples

1
2
data(iris)
iris.md <- distance(iris[,1:4], "mahal")


ecodist documentation built on May 19, 2017, 7:21 p.m.
Search within the ecodist package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.

Please suggest features or report bugs in the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.