flatten.dendrogram | R Documentation |
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.
flatten.dendrogram(dend, FUN = max, new_height, ...)
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) |
A dendrogram with both of the root's branches of the same height
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")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.