Learn R Programming

ribiosPlot (version 1.3.0)

robustDist: 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, ...)

Value

The same as dist, however without NAs.

Arguments

x

a numeric matrix, data frame or ‘dist’ object

...

Other parameters passed to the dist function.

Author

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

Details

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

Examples

Run this code

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)

Run the code above in your browser using DataLab