R: Search for the subdendrogram structure composed of indicated...

find_dendrogram {dendextend} | R Documentation

## 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

    ## 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")

    ## End(Not run)

[Package dendextend version 1.8.0 Index]