Pairwise distance between groups
dist computes distances between every pair of elements in a group: gdist takes two arguments, and returns the matrix of distances wrt every possible pair with one argument from each group. General Mahalanobis metrics are also allowed.
n1 x d matrix with n1 data elements.
n2 x d matrix with n2 data elements.
If NULL, defaults to identity (i.e. Euclidean distance). A d x d matrix is assumed as a sample covariance matrix, and its inverse is used to compute distances (i.e. Mahalanobis distance). Likewise, a list of n2 d x d matrices can be provided, yielding distances specific to each row in g2.
This function is especially useful to make algorithms such as k-means (or mkmeans in the package) more efficient - rows in g1 are then generally the data set, and in g2 respectively cluster centres.
n1 x n2 matrix of distances
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.