1% File src/library/stats/man/order.dendrogram.Rd
2% Part of the R package, https://www.R-project.org
3% Copyright 1995-2010 R Core Team
4% Copyright 2002-2010 The R Foundation
5% Distributed under GPL 2 or later
6
7\name{order.dendrogram}
8\alias{order.dendrogram}
9\alias{labels.dendrogram}
10\title{Ordering or Labels of the Leaves in a Dendrogram}
11\description{
12  Theses functions return the order (index) or the \code{"label"}
13  attribute for the leaves in a
14  dendrogram.  These indices can then be used to access the appropriate
15  components of any additional data.
16}
17\usage{
18order.dendrogram(x)
19
20\method{labels}{dendrogram}(object, \dots)
21}
22\arguments{
23  \item{x, object}{a dendrogram (see \code{\link{as.dendrogram}}).}
24  \item{\dots}{additional arguments}
25}
26\details{
27  The indices or labels for the leaves in left to right order are retrieved.
28}
29\value{
30  A vector with length equal to the number of leaves in the dendrogram
31  is returned.  From \code{r <- order.dendrogram()}, each element is the
32  index into the original data (from which the dendrogram was computed).
33}
34\author{R. Gentleman (\code{order.dendrogram}) and Martin Maechler
35  (\code{labels.dendrogram}).}
36
37\seealso{\code{\link{reorder}}, \code{\link{dendrogram}}.
38}
39\examples{
40set.seed(123)
41x <- rnorm(10)
42hc <- hclust(dist(x))
43hc$order
44dd <- as.dendrogram(hc)
45order.dendrogram(dd) ## the same :
46stopifnot(hc$order == order.dendrogram(dd))
47
48d2 <- as.dendrogram(hclust(dist(USArrests)))
49labels(d2) ## in this case the same as
50stopifnot(identical(labels(d2),
51   rownames(USArrests)[order.dendrogram(d2)]))
52}
53\keyword{manip}
54