cuttree {lazy.cluster}R Documentation

Cut a (Short) Tree into Groups of Data

Description

Cuts a tree, e.g., as resulting from hclust or dhclust , into several groups either by specifying the desired number(s) of groups or the cut height(s).

Usage

cuttree(tree = NULL, k = NULL, h = NULL, debug = 0)

Arguments

tree

A tree as produced by hclust or dhclust.

k

an integer scalar or vector with the desired number of groups

h

numeric scalar or vector with heights where the tree should be cut.

debug

= 1 to print intermediate result

Details

This function uses native cutree if the tree is usual full tree object.
When tree contains short tree created by dhclust, i.e.,
tree$method == "dhclust" & nrow(tree$merge) + 1 < tree$param$nobs
it uses the information contained in tree$bottoml, tree$param$ndiv , tree$labels .

Value

Same as the result of cutree except that cuttree always return a matrix. Also, the rowname(cuttree(tree,k)) is set equal to the labels or ids.

Examples

Y <- demodata[,1:8]
set.seed(1701)
resY3 <- dhclust( Y, maxclustersize=3 )
res1=cutree( resY3$tree_l,3 )
res2=cuttree( resY3$tree_s,3 )
Print(res1,res2)


[Package lazy.cluster version 0.1.2 Index]