.BG
.VE $Header: /usr3/s/current/s/.help/RCS/clorder,v 1.2 83/12/30 19:25:24 rab Exp $
.FN clorder
.TL
clorder: Re-Order Leaves of a Cluster Tree
.CS
clorder(tree, x)
.PP
.AG tree
structure with components named `merge', `height', and
`order', typically a hierarchical clustering
produced by function `hclust'.
.AG x
numeric vector with one value for each individual involved
in the cluster tree.
.RT
cluster tree structure with the `merge' and `order' components
permuted so that at any merge, the cluster with the smaller
average `x' value is on the left.
This reorders `tree' so that the leaves
are approximately in order by the associated `x' values.
.PP
In hierarchical cluster displays, a decision is needed
at each merge to specify which subtree should go on the left
and which on the right.
Since, for `n' individuals, there are `n\-1' merges, there are
`2^(n\-1)' possible orderings for the leaves in a cluster tree.
The default algorithm in `hclust' is to order the 
subtrees so that the tighter cluster is on the left
(the last merge of the left subtree is at a lower value than
the last merge of the right subtree).
Individuals are the tightest clusters possible, and merges involving
two individuals place them in order by their observation number.
.EX
h <- hclust(dist(votes.repub))
ave.repub <- ?row(votes.repub,mean)
h2 <- clorder(h,ave.repub)  #leaves ordered by
    # average republican vote
plclust(h2, lab=state.abb)  #cluster plot
.KW cluster
.WR
