robustDist | R Documentation |
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.
robustDist(x, ...)
x |
a numeric matrix, data frame or ‘dist’ object |
... |
Other parameters passed to the |
In the rare case of all-NA distance matrices, all values are assigned arbitrarily to one.
The same as dist
, however without NA
s.
Jitao David Zhang <jitao_david.zhang@roche.com>
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.