if (FALSE) {
# define dendrogram object to play with:
dend <- iris[, -5] %>%
dist() %>%
hclust() %>%
as.dendrogram() %>%
set("labels_to_character") %>%
color_branches(k = 5)
first.subdend.only <- names(cutree(dend, 4)[cutree(dend, 4) == 1])
sub.dend <- find_dendrogram(dend, first.subdend.only)
# Plotting the result
par(mfrow = c(1, 2))
plot(dend, main = "Original dendrogram")
plot(sub.dend, main = "First subdendrogram")
dend <- 1:10 %>%
dist() %>%
hclust() %>%
as.dendrogram() %>%
set("labels_to_character") %>%
color_branches(k = 5)
selected_labels <- as.character(1:4)
sub_dend <- find_dendrogram(dend, selected_labels)
plot(dend, main = "Original dendrogram")
plot(sub_dend, main = "First subdendrogram")
}
Run the code above in your browser using DataLab