.BG
.FN clorder
.TL
Re-Order Leaves of a Cluster Tree
.CS
clorder(tree, x)
.AG tree
list 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.
.SA
`hclust' for the basic definition of the clustering method and structure.
.EX
h <- hclust(dist(votes.repub))
namean <- function(x) mean(x[!is.na(x)])
ave.repub <- apply(votes.repub, 1, namean)

# leaves ordered by average republican vote
h2 <- clorder(h, ave.repub)

plclust(h2, lab=state.abb)  #cluster plot
.KW cluster
.WR
