compute_dmat: Compute a distance matrix from scaled data

View source: R/utils_clustering.R

compute_dmatR Documentation

Compute a distance matrix from scaled data

Description

This function applies scaling to the columns of a data frame and computes and returns a distance matrix from a chosen distance measure.

Usage

compute_dmat(
  x,
  dist_method = "euclidean",
  apply_scaling = FALSE,
  subset_cols = NULL
)

Arguments

x

a numeric data frame or matrix

dist_method

a distance measure to apply to the scaled data. Must be those supported by stats::dist(), plus "mahalanobis" and "cosine". Default is "euclidean".

apply_scaling

use TRUE to apply base::scale(). By default does not scale data.

subset_cols

(optional) a list of columns to subset the data

Value

an object of class "dist" (see stats::dist())

Examples

dmat <- compute_dmat(iris, "euclidean", TRUE, c("Petal.Length", "Sepal.Length"))
print(class(dmat))

visxhclust documentation built on March 31, 2023, 7:30 p.m.