Skip to contents

These functions provide convenient constructors for various types of distance functions. Each constructor function initializes a distance function object for use with distance computation functions, specifying the method and any necessary labels.

Usage

cordist(labels = NULL, method = c("pearson", "spearman"))

mahadist(labels = NULL)

eucdist(labels = NULL)

robustmahadist(labels = NULL)

pcadist(
  labels = NULL,
  ncomp = 2,
  whiten = TRUE,
  threshfun = NULL,
  dist_method = c("euclidean", "manhattan", "cosine")
)

Arguments

labels

A vector of labels associated with the data points.

method

The method of distance computation, applicable for `cordist`.

Value

An object of class `distfun` with a specific method subclass, encapsulating all information necessary for computing distances according to the specified method.

Details

The constructors allow for the specification of distance calculation methods and associated labels: - `cordist` creates a correlation distance function. - `mahadist` creates a Mahalanobis distance function. - `eucdist` creates a Euclidean distance function. - `robustmahadist` creates a robust version of the Mahalanobis distance function.

See also

create_dist for the underlying constructor used by these functions.

Examples

dist_obj_1 <- cordist(labels = c("A", "B", "C"), method = "pearson")
dist_obj_2 <- mahadist(labels = c("A", "B", "C"))
#> Error in mahadist(labels = c("A", "B", "C")): could not find function "mahadist"
dist_obj_3 <- eucdist(labels = c("A", "B", "C"))
#> Error in eucdist(labels = c("A", "B", "C")): could not find function "eucdist"
dist_obj_4 <- robustmahadist(labels = c("A", "B", "C"))
#> Error in robustmahadist(labels = c("A", "B", "C")): could not find function "robustmahadist"