flatten.dendrogram: Flatten the branches of a dendrogram's root

View source: R/unbranch.R

flatten.dendrogramR Documentation

Flatten the branches of a dendrogram's root

Description

The function makes sure the two branches of the root of a dendrogram will have the same height. The user can choose how to decide which height to use.

Usage

flatten.dendrogram(dend, FUN = max, new_height, ...)

Arguments

dend

dendrogram object

FUN

how to choose the new height of both branches (defaults to taking the max between the two)

new_height

overrides FUN, and sets the new height of the two branches manually

...

passed on (not used)

Value

A dendrogram with both of the root's branches of the same height

Examples

hc <- hclust(dist(USArrests[2:9, ]), "com")
dend <- as.dendrogram(hc)
attr(dend[[1]], "height") <- 150 # make the height un-equal

par(mfrow = c(1, 2))
plot(dend, main = "original tree")
plot(flatten.dendrogram(dend), main = "Raised tree")

dendextend documentation built on Oct. 13, 2024, 1:06 a.m.