dendextend (version 1.13.2)

find_dendrogram: Search for the subdendrogram structure composed of indicated labels

Description

Given a dendrogram object, the function performs a recursive DFS algorithm to determine the subdendrogram which is composed of all indicated labels. The labels which should compose the subdendrogram are marked as TRUE in the logical vector of length nleaves(dend)

Usage

find_dendrogram(dend, selected_labels)

Arguments

dend

a dendrogram object

selected_labels

logical vector with TRUE values at positions of members which should be included in the resulting subdendrogram

Value

A subdendrogram composed of only members indicated in the given logical vector clusters.

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# define dendrogram object to play with:
dend <- iris[, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram() %>%
  set("labels_to_character") %>%
  color_branches(k = 5)
first.subdend.only <- 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")
# }
# NOT RUN {
# }

Run the code above in your browser using DataCamp Workspace