product_metric: Product metric

Description Usage Arguments Examples

View source: R/product_metric.R

Description

Returns the p-product metric of two metric spaces. Works for output of 'rdist', 'pdist' or 'cdist'.

Usage

1

Arguments

...

Distance matrices or dist objects

p

The power of the Minkowski distance

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
# 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)

rdist documentation built on May 4, 2020, 5:13 p.m.