Returns a vector of group numbers for the observations that were clustered.
Either the number of groups desired, or a clustering height are to be
specified.
USAGE:
cutree(tree, k = 0, h = 0)
REQUIRED ARGUMENTS:
tree
hierarchical clustering tree structure, typically the output
of
hclust.
Exactly one of
k or
h must be supplied.
OPTIONAL ARGUMENTS:
k
the desired number of groups. Default is 0.
h
the height at which to cut
tree in order to
produce the groups. Groups will be defined by the structure
of the tree above the cut. Default is 0.
VALUE:
vector with as many elements as there are leaves
in the tree. The
ith element of the vector gives the
group number to which individual
i is assigned. Individuals
not in the current tree (if
tree was a subtree from a
larger original problem) are assigned group 0.
Attribute
height is a
vector with as many values as there are resulting groups,
the ith value gives the height of the last merge making
up the group. Singleton clusters are given height 0.
SEE ALSO:
,
,
,
.
EXAMPLES:
vote.cl <- hclust(dist(votes.repub))
group <- cutree(vote.cl, k=5) # produce 5 groups
state.name[group==1]