\HeaderA{order.dendrogram}{Ordering or Labels of the Leaves in a Dendrogram}{order.dendrogram}
\aliasA{labels.dendrogram}{order.dendrogram}{labels.dendrogram}
\keyword{manip}{order.dendrogram}
\begin{Description}\relax
Theses functions return the order (index) or the \code{"label"}
attribute for the leaves in a
dendrogram.  These indices can then be used to access the appropriate
components of any additional data.
\end{Description}
\begin{Usage}
\begin{verbatim}
order.dendrogram(x)

## S3 method for class 'dendrogram':
labels(object, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{x, object}] a dendrogram (see \code{\LinkA{as.dendrogram}{as.dendrogram}}).
\item[\code{...}] additional arguments
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The indices or labels for the leaves in left to right order are retrieved.
\end{Details}
\begin{Value}
A vector with length equal to the number of leaves in the dendrogram
is returned.  From \code{r <- order.dendrogram()}, each element is the
index into the original data (from which the dendrogram was computed).
\end{Value}
\begin{Author}\relax
R. Gentleman (\code{order.dendrogram} and Martin Maechler
(\code{labels.dendrogram}).
\end{Author}
\begin{SeeAlso}\relax
\code{\LinkA{reorder}{reorder}}, \code{\LinkA{dendrogram}{dendrogram}}.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
set.seed(123)
x <- rnorm(10)
hc <- hclust(dist(x))
hc$order
dd <- as.dendrogram(hc)
order.dendrogram(dd) ## the same :
stopifnot(hc$order == order.dendrogram(dd))

d2 <- as.dendrogram(hclust(dist(USArrests)))
labels(d2) ## in this case the same as
stopifnot(labels(d2) == rownames(USArrests)[order.dendrogram(d2)])
\end{ExampleCode}
\end{Examples}

