cordist | R Documentation |
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.
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")
)
labels |
A vector of labels associated with the data points. |
method |
The method of distance computation, applicable for 'cordist'. |
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.
An object of class 'distfun' with a specific method subclass, encapsulating all information necessary for computing distances according to the specified method.
create_dist
for the underlying constructor used by these functions.
dist_obj_1 <- cordist(labels = c("A", "B", "C"), method = "pearson")
dist_obj_2 <- mahadist(labels = c("A", "B", "C"))
dist_obj_3 <- eucdist(labels = c("A", "B", "C"))
dist_obj_4 <- robustmahadist(labels = c("A", "B", "C"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.