pairwise_dist: Generic Pairwise Distance Computation

View source: R/allgeneric.R

pairwise_distR Documentation

Generic Pairwise Distance Computation

Description

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'.

Usage

pairwise_dist(obj, X, ...)

Arguments

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.

Details

'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.

Value

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'.

See Also

dist for default distance computations in R.

Examples

# 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)


bbuchsbaum/rMVPA documentation built on April 28, 2024, 6:30 a.m.