robustDist: Robust distance

View source: R/robustdist.R

robustDistR Documentation

Robust distance

Description

A wrapper function for the dist function in the stats package. It replaces NA values in the distance matrix by the maximum distance in the same matrix, therefore prevents cases where hclust fails because of NA distances.

Usage

robustDist(x, ...)

Arguments

x

a numeric matrix, data frame or ‘dist’ object

...

Other parameters passed to the dist function.

Details

In the rare case of all-NA distance matrices, all values are assigned arbitrarily to one.

Value

The same as dist, however without NAs.

Author(s)

Jitao David Zhang <jitao_david.zhang@roche.com>

Examples


mymat <- matrix(c(3,2,1,NA,NA,NA,
                4,1,2,NA,NA,NA,
                NA,NA,NA,5,1,2), ncol=6, byrow=TRUE)
dist(mymat)
robustDist(mymat)


bedapub/ribiosPlot documentation built on Sept. 1, 2023, 6:50 p.m.