as.hclust
Convert Objects to Class hclust
Converts objects from other hierarchical clustering functions to
class "hclust"
.
- Keywords
- multivariate, cluster
Usage
as.hclust(x, ...)
Arguments
- x
- Hierarchical clustering object
- ...
- further arguments passed to or from other methods.
Details
Currently there is only support for converting objects of
class "twins"
as produced by the functions diana
and
agnes
from the package \href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}clustercluster. The default method
throws an error unless passed an "hclust"
object.
Value
-
An object of class
"hclust"
.
See Also
hclust
, and from package \href{https://CRAN.R-project.org/package=#1}{\pkg{#1}}clustercluster,
diana
and agnes
Examples
library(stats)
x <- matrix(rnorm(30), ncol = 3)
hc <- hclust(dist(x), method = "complete")
if(require("cluster", quietly = TRUE)) {# is a recommended 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)
detach("package:cluster")
}
Community examples
Looks like there are no examples yet.