| as.hclust {mva} | R Documentation |
Converts objects from other hierarchical clustering functions to
class "hclust".
as.hclust(x, ...) as.hclust.default(x, ...) as.hclust.twins(x, ...)
x |
Hierarchical clustering object |
... |
further arguments passed to or from other methods. |
Currently there is only support for converting objects of
class "twins" as produced by the functions diana and
agnes from the package `cluster'.
An object of class "hclust".
x <- matrix(rnorm(30), ncol=3)
hc <- hclust(dist(x), method="complete")
if(require(cluster)) {# is a required package
ag <- agnes(x, method="complete")
hcag <- as.hclust(ag)
## The dendrograms order slightly differently:
op <- par(mfrow=c(1,2))
plot(hc) ; mtext("hclust", side=1)
plot(hcag); mtext("agnes", side=1)
}
stopifnot(identical(hc, hhc <- as.hclust(hc)),
identical(hhc, as.hclust(hhc)))