create_dist | R Documentation |
Constructs a generic distance function object, storing:
name
: The name (method) of the distance (e.g., "euclidean", "cordist", "mahalanobis").
labels
: (Optional) a vector of labels associated with the data rows.
...
: Additional parameters relevant to the specific distance method
(e.g., correlation method for cordist
, number of components for pcadist
, etc.).
create_dist(name, labels = NULL, ...)
name |
A character string specifying the distance method (e.g., "euclidean", "cordist"). |
labels |
A vector of row labels (optional), primarily for informational/reference purposes. |
... |
Additional parameters for the distance method (e.g. 'method="pearson"' for correlation,
or |
This object is used by pairwise_dist()
to compute an N x N matrix of pairwise distances
between rows of a data matrix.
The distance function object itself does not exclude same-block comparisons or reorder rows by label.
Those tasks (if needed) are handled downstream (for example, in second_order_similarity
).
An S3 object with class c(name, "distfun")
that can be passed to pairwise_dist()
.
# Create a Euclidean distance function object
dist_obj_euc <- create_dist("euclidean")
# Create a correlation distance function object with a specified correlation method
dist_obj_cor <- create_dist("cordist", method="spearman")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.