pairwise_dist | R Documentation |
This function acts as a generic interface for computing pairwise distances between the rows of a matrix X. The actual computation is delegated to method-specific functions depending on the class of 'dist_obj'.
pairwise_dist(obj, X, ...)
X |
A numeric matrix where each row is considered as a data point between which distances are to be calculated. The matrix should not contain any missing values as this may affect the accuracy and performance of the distance computations. |
... |
Additional arguments to be passed to the method-specific distance functions. |
dist_obj |
A distance object which specifies the type of distance measure to be used and potentially contains additional parameters needed for distance calculation. The class of 'dist_obj' determines which method is dispatched. |
'pairwise_dist' is a generic function meant to interface with various methods for distance computation. Users must provide a 'dist_obj' which includes specifics about the distance measure to be used. The actual computation is handled by method-specific functions that should be defined for different classes of 'dist_obj'. These functions must be registered with the appropriate S3 method for 'pairwise_dist' such as 'pairwise_dist.default', 'pairwise_dist.correlation', etc.
Depending on the specific method implementation, this function typically returns a numeric matrix or an object of class 'dist' representing the pairwise distances between the rows of 'X'.
dist
for default distance computations in R.
# Assuming a correlation-based distance object and matrix X
dist_obj <- correlation_dist_object(parameters)
X <- matrix(rnorm(100), ncol = 10)
distances <- pairwise_dist(dist_obj, X)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.