dist: Customized Distance Function

Description Usage Arguments Note Examples

View source: R/custom_dist.R

Description

Based on dist. Additionally it can handle correlation-based distances and has argument for imputation of NA distances. To avoid confusion with stats::dist all the default settings are such that it performs equivalently to the aforementioned one.

Usage

1
dist(x, method = "euclidean", na.avg = FALSE, ...)

Arguments

x

a numeric matrix

method

the distance measure to be used. This must be one of "euclidean", "maximum", "manhattan", "canberra", "binary", "minkowski", "pearson", "kendall", "spearman". Any unambiguous substring can be given.

na.avg

logical if yes, then NA distance will be imputed with average distance value. Default is FALSE.

...

arguments of dist

Note

In the current set-up corrlation values -1, 0 and 1 correspond to distances 1, 0.5 and 1, respectively.
R=1 -> dist=0
R=0 -> dist=0.5
R=-1 -> dist=1

Examples

1
2
3
4
x <- matrix(c(1:5, 5:9, 9:13), ncol=3)
stats::dist(x)
dist(x)
dist(x, method="pearson")

vladpetyuk/vp.misc documentation built on June 25, 2021, 6:35 a.m.