slice: Cut a tree-like object into groups numbered in tree order
Description
In comparison with cutree, the groups are numbered from left to right as per
the tree when plotted in its standard horizontal form. Note also that the
return value will have the leaves sorted in dendrogram order.
Usage
slice(x, k = NULL, h = NULL, ...)
Value
a named vector with group memberships
Arguments
x
tree like object
k
an integer scalar with the desired number of groups
h
numeric scalar with height where the tree should be cut
hc <- hclust(dist(USArrests), "ave")
# return groups, leaves ordered by dendrogramslice(hc,k=5)
# return groups, leaves ordered as originally passed to hclustslice(hc,k=5)[order(hc$order)]