dendrogram {mva} | R Documentation |
Class "dendrogram"
provides general functions for handling
tree-like structures. It is intended as a replacement for similar
functions in hierarchical clustering and classification/regression
trees, such that all of these can use the same engine for plotting or
cutting trees. Currently the code is in alpha stage and the API may
change at any point in time.
plot(x, type=c("rectangle", "triangle"), center=FALSE, xlab="", ylab="", ...) cut(x, h, ...)
x |
Object of class "dendrogram" . |
type |
Type of plot. |
center |
If TRUE , nodes are plotted centered with respect to
the leaves in the branch. Default is to plot them in the middle of all
direct child nodes. |
h |
Height at which the tree is cutted. |
..., xlab, ylab |
graphical parameters, or arguments for other methods. |
Warning: This documentation is preliminary.
The dendrogram is directly represented as a nested list, where each list
component corresponds to a branch of the tree. Hence, the first branch
of tree z
is z[[1]]
, the second branch of the
corresponding subtree is z[[1]][[2]]
etc.. Each node of the tree
carries some information needed for efficient plotting or cutting as
attributes:
members
height
midpoint
text
edgetext
Terminal nodes (leaves of the tree) can have arbitrary value but must not be a list.
cut.dendrogram()
returns a list with components $upper
and
$lower
, the first is a truncated version of the original tree,
also of class dendrogram
,
the latter a list with the branches obtained from cutting the tree,
each a dendrogram
.
Objects of class "hclust"
can be converted to class
"dendrogram"
using method as.dendrogram
.
plotNode()
and plotNodeLimit()
are helper functions.
library(mva) data(USArrests) hc <- hclust(dist(USArrests), "ave") str(dend1 <- as.dendrogram(hc)) plot(dend1) dend2 <- cut(dend1, h=70) plot(dend2$upper) plot(dend2$lower[[3]])