
Last chance! 50% off unlimited learning
Sale ends in
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.
slice(x, k = NULL, h = NULL, ...)
tree like object
an integer scalar with the desired number of groups
numeric scalar with height where the tree should be cut
Additional parameters passed to methods
a named vector with group memberships
# NOT RUN {
hc <- hclust(dist(USArrests), "ave")
# return groups, leaves ordered by dendrogram
slice(hc,k=5)
# return groups, leaves ordered as originally passed to hclust
slice(hc,k=5)[order(hc$order)]
# }
Run the code above in your browser using DataLab