Distance: Compute a distance matrix

View source: R/distance.R

DistanceR Documentation

Compute a distance matrix

Description

Dispatcher computing an object-by-object distance matrix under a range of measures suitable for continuous, binary and mixed-type data.

Usage

Distance(
  Data,
  distmeasure = c("tanimoto", "jaccard", "euclidean", "hamming", "cont tanimoto",
    "MCA_coord", "gower", "chi.squared", "cosine"),
  normalize = NULL,
  method = NULL
)

Distance_v2(Data, distmeasure = "tanimoto", normalize = NULL)

Arguments

Data

A data matrix; rows are the objects.

distmeasure

One of "tanimoto", "jaccard", "euclidean" (true Euclidean, via stats::dist), "gower" (mixed-type, via FD::gowdis), "hamming", "cont tanimoto", "MCA_coord", "chi.squared", "cosine".

normalize

Optional normalisation method (see Normalization), applied for the "euclidean" / "cont tanimoto" measures.

method

Ignored; retained for backward compatibility.

Details

"cosine", "chi.squared" and "MCA_coord" require the suggested packages lsa, analogue and FactoMineR respectively.

Value

A symmetric numeric distance matrix.

Examples

m <- matrix(rbinom(40, 1, 0.5), nrow = 8)
D <- Distance(m, distmeasure = "tanimoto")
dim(D)

MosaiClusteR documentation built on Oct. 25, 2026, 1:08 a.m.