1% File src/library/stats/man/reorder.dendrogram.Rd 2% Part of the R package, https://www.R-project.org 3% Copyright 1995-2007 R Core Team 4% Distributed under GPL 2 or later 5 6\name{reorder.dendrogram} 7\alias{reorder.dendrogram} 8\title{Reorder a Dendrogram} 9\description{ 10 A method for the generic function \code{\link{reorder}}. 11 12 There are many different orderings of a dendrogram that are consistent 13 with the structure imposed. This function takes a dendrogram and a 14 vector of values and reorders the dendrogram in the order of the 15 supplied vector, maintaining the constraints on the dendrogram. 16} 17\usage{ 18\method{reorder}{dendrogram}(x, wts, agglo.FUN = sum, \dots) 19} 20\arguments{ 21 \item{x}{the (dendrogram) object to be reordered} 22 \item{wts}{numeric weights (arbitrary values) for reordering.} 23 \item{agglo.FUN}{a function for weights agglomeration, see below.} 24 \item{\dots}{additional arguments} 25} 26\details{ 27 Using the weights \code{wts}, the leaves of the dendrogram are 28 reordered so as to be in an order as consistent as possible with the 29 weights. At each node, the branches are ordered in 30 increasing weights where the weight of a branch is defined as 31 \eqn{f(w_j)} where \eqn{f} is \code{agglo.FUN} and \eqn{w_j} is the 32 weight of the \eqn{j}-th sub branch. 33} 34\value{ 35 A dendrogram where each node has a further attribute \code{value} with 36 its corresponding weight. 37} 38\author{R. Gentleman and M. Maechler} 39\seealso{ 40 \code{\link{reorder}}. 41 42 \code{\link{rev.dendrogram}} which simply reverses the nodes' 43 order; \code{\link{heatmap}}, \code{\link{cophenetic}}. 44} 45\examples{ 46require(graphics) 47 48set.seed(123) 49x <- rnorm(10) 50hc <- hclust(dist(x)) 51dd <- as.dendrogram(hc) 52dd.reorder <- reorder(dd, 10:1) 53plot(dd, main = "random dendrogram 'dd'") 54 55op <- par(mfcol = 1:2) 56plot(dd.reorder, main = "reorder(dd, 10:1)") 57plot(reorder(dd, 10:1, agglo.FUN = mean), main = "reorder(dd, 10:1, mean)") 58par(op) 59} 60\keyword{manip} 61