| Line 1... |
Line 1... |
| 1 |
% File src/library/stats/man/dendrogram.Rd
|
1 |
% File src/library/stats/man/dendrogram.Rd
|
| 2 |
% Part of the R package, http://www.R-project.org
|
2 |
% Part of the R package, http://www.R-project.org
|
| 3 |
% Copyright 1995-2011 R Core Team
|
3 |
% Copyright 1995-2014 R Core Team
|
| 4 |
% Copyright 2002-2011 The R Foundation
|
4 |
% Copyright 2002-2014 The R Foundation
|
| 5 |
% Distributed under GPL 2 or later
|
5 |
% Distributed under GPL 2 or later
|
| 6 |
|
6 |
|
| 7 |
\name{dendrogram}
|
7 |
\name{dendrogram}
|
| 8 |
\title{General Tree Structures}
|
8 |
\title{General Tree Structures}
|
| 9 |
\alias{dendrogram}% the class
|
9 |
\alias{dendrogram}% the class
|
| Line 158... |
Line 158... |
| 158 |
tree, also of class \code{dendrogram}, the latter a list with the
|
158 |
tree, also of class \code{dendrogram}, the latter a list with the
|
| 159 |
branches obtained from cutting the tree, each a \code{dendrogram}.
|
159 |
branches obtained from cutting the tree, each a \code{dendrogram}.
|
| 160 |
|
160 |
|
| 161 |
There are \code{\link{[[}}, \code{\link{print}}, and \code{\link{str}}
|
161 |
There are \code{\link{[[}}, \code{\link{print}}, and \code{\link{str}}
|
| 162 |
methods for \code{"dendrogram"} objects where the first one
|
162 |
methods for \code{"dendrogram"} objects where the first one
|
| 163 |
(extraction) ensures that selecting sub-branches keeps the class.
|
163 |
(extraction) ensures that selecting sub-branches keeps the class,
|
| - |
|
164 |
i.e., returns a dendrogram even if only a leaf.
|
| - |
|
165 |
On the other hand, \code{\link{[}} (\emph{single} bracket) extraction
|
| - |
|
166 |
returns the underlying list structure.%, useful, e.g., for inspection.
|
| 164 |
|
167 |
|
| 165 |
Objects of class \code{"hclust"} can be converted to class
|
168 |
Objects of class \code{"hclust"} can be converted to class
|
| 166 |
\code{"dendrogram"} using method \code{as.dendrogram()}, and since R
|
169 |
\code{"dendrogram"} using method \code{as.dendrogram()}, and since R
|
| 167 |
2.13.0, there is also a \code{\link{as.hclust}()} method as an inverse.
|
170 |
2.13.0, there is also a \code{\link{as.hclust}()} method as an inverse.
|
| 168 |
|
171 |
|
| Line 233... |
Line 236... |
| 233 |
par(op)
|
236 |
par(op)
|
| 234 |
d3 <- dend2$lower[[2]][[2]][[1]]
|
237 |
d3 <- dend2$lower[[2]][[2]][[1]]
|
| 235 |
stopifnot(identical(d3, dend2$lower[[2]][[c(2,1)]]))
|
238 |
stopifnot(identical(d3, dend2$lower[[2]][[c(2,1)]]))
|
| 236 |
str(d3, last.str = "'")
|
239 |
str(d3, last.str = "'")
|
| 237 |
|
240 |
|
| - |
|
241 |
## to peak at the inner structure "if you must", use '[..]' indexing :
|
| - |
|
242 |
str(d3[2][[1]]) ## or the full
|
| - |
|
243 |
str(d3[])
|
| - |
|
244 |
|
| 238 |
## merge() to join dendrograms:
|
245 |
## merge() to join dendrograms:
|
| 239 |
(d13 <- merge(dend2$lower[[1]], dend2$lower[[3]]))
|
246 |
(d13 <- merge(dend2$lower[[1]], dend2$lower[[3]]))
|
| 240 |
## merge() all parts back (using default 'height' instead of original one):
|
247 |
## merge() all parts back (using default 'height' instead of original one):
|
| 241 |
den.1 <- Reduce(merge, dend2$lower)
|
248 |
den.1 <- Reduce(merge, dend2$lower)
|
| 242 |
## or merge() all four parts at same height --> 4 branches (!)
|
249 |
## or merge() all four parts at same height --> 4 branches (!)
|