Cut a tree (result from hclust) into groups of data. Groups are in the order of the tree leafs.

cutree.order(tree, k = NULL, h = NULL)

Arguments

tree

an hclust object

k

the desired number of groups

h

height where the tree is to be cut

Note

The A2R package has not been updated since January 2006 and cannot be installed anymore with a recent version of R. It's why this function has been copied here.

See also

Author

Romain Francois

Examples

h77 <- hclust(dist(state.x77))
ct.o <- cutree.order(h77, k = 4)
ct.n <- cutree(h77, k = 4)
plot(h77)
rect.hclust(h77, 4)

cbind(ct.o, ct.n)
#>                ct.o ct.n
#> Alabama           4    1
#> Alaska            1    2
#> Arizona           3    3
#> Arkansas          4    1
#> California        3    3
#> Colorado          3    3
#> Connecticut       4    1
#> Delaware          4    1
#> Florida           4    1
#> Georgia           4    1
#> Hawaii            4    1
#> Idaho             4    1
#> Illinois          4    1
#> Indiana           4    1
#> Iowa              4    1
#> Kansas            4    1
#> Kentucky          4    1
#> Louisiana         4    1
#> Maine             4    1
#> Maryland          4    1
#> Massachusetts     4    1
#> Michigan          4    1
#> Minnesota         4    1
#> Mississippi       4    1
#> Missouri          4    1
#> Montana           3    3
#> Nebraska          4    1
#> Nevada            3    3
#> New Hampshire     4    1
#> New Jersey        4    1
#> New Mexico        3    3
#> New York          4    1
#> North Carolina    4    1
#> North Dakota      4    1
#> Ohio              4    1
#> Oklahoma          4    1
#> Oregon            3    3
#> Pennsylvania      4    1
#> Rhode Island      4    1
#> South Carolina    4    1
#> South Dakota      4    1
#> Tennessee         4    1
#> Texas             2    4
#> Utah              4    1
#> Vermont           4    1
#> Virginia          4    1
#> Washington        4    1
#> West Virginia     4    1
#> Wisconsin         4    1
#> Wyoming           3    3