product_metric {rdist} | R Documentation |
Product metric
Description
Returns the p-product metric of two metric spaces. Works for output of 'rdist', 'pdist' or 'cdist'.
Usage
product_metric(..., p = 2)
Arguments
... |
Distance matrices or dist objects |
p |
The power of the Minkowski distance |
Examples
# generate data
df <- matrix(runif(200), ncol = 2)
# distance matrices
dist_mat <- pdist(df)
dist_1 <- pdist(df[, 1])
dist_2 <- pdist(df[, 2])
# product distance matrix
dist_prod <- product_metric(dist_1, dist_2)
# check equality
all.equal(dist_mat, dist_prod)
[Package rdist version 0.0.5 Index]