is.cl_hierarchy(x)
is.cl_dendrogram(x)as.cl_hierarchy(x)
as.cl_dendrogram(x)
For the coercion functions, a container object inheriting from
"cl_hierarchy"
, with a suitable representation of the hierarchy
given by x
.
The methods provided in package
The hierarchies considered by "cl_hierarchy"
and
"cl_dendrogram"
(which inherits from the former),
respectively.
$n$-trees on a set $X$ of objects correspond to collections $H$ of subsets of $X$, usually called classes of the hierarchy, which satisfy the following properties:
The classes of a hierarchy can be obtained by
cl_classes
.
Dendrograms are $n$-trees where additionally a height $h$ is associated with each of the classes, so that for two classes $A$ and $B$ with non-empty intersection we have $h(A) \le h(B)$ iff $A$ is a subset of $B$. For each pair of objects one can then define $u_{ij}$ as the height of the smallest class containing both $i$ and $j$: this results in a dissimilarity on $X$ which satisfies the ultrametric (3-point) conditions $u_{ij} \le \max(u_{ik}, u_{jk})$ for all triples $(i, j, k)$ of objects. Conversely, an ultrametric dissimilarity induces a unique dendrogram.
The ultrametric dissimilarities of a dendrogram can be obtained by
cl_ultrametric
.
as.cl_hierarchy
returns an object of class
"cl_hierarchy"
x
if
this already represents a hierarchy (i.e., is.cl_hierarchy(x)
is true), or the ultrametric obtained from x
via
as.cl_ultrametric
.
as.cl_dendrogram
returns an object which has class
"cl_dendrogram"
and inherits from "cl_hierarchy"
,
and contains x
if it represents a dendrogram (i.e.,
is.cl_dendrogram(x)
is true), or the ultrametric obtained from
x
.
Conceptually, hierarchies and dendrograms are virtual classes,
allowing for a variety of representations.
There are group methods for comparing dendrograms and computing their
minimum, maximum, and range based on the meet and join operations, see
cl_meet
. There is also a plot method.
hcl <- hclust(dist(USArrests))
is.cl_dendrogram(hcl)
is.cl_hierarchy(hcl)
Run the code above in your browser using DataLab