This function identifies which edge(s) in a tree has group of labels ("tips") in common. By default it only returns the edge (node) with the heighest id.
which_node(dend, labels, max_id = TRUE, ...)
An integer with the id(s) of the nodes which includes all of the labels.
dend <- iris[1:10, -5] %>%
dist() %>%
hclust() %>%
as.dendrogram() %>%
set("labels", 1:10)
dend %>% plot()
which_node(dend, c(1, 2), max_id = FALSE)
#> [1] 1 2
which_node(dend, c(2, 3), max_id = FALSE)
#> [1] 1 2 4 5
which_node(dend, c(2, 3))
#> [1] 5
dend %>% plot()
the_h <- get_nodes_attr(dend, "height", which_node(dend, c(4, 6)))
the_h
#> [1] 0.3316625
abline(h = the_h, lty = 2, col = 2)
get_nodes_attr(dend, "height", which_node(dend, c(4, 6)))
#> [1] 0.3316625
get_nodes_attr(dend, "members", which_node(dend, c(4, 6)))
#> [1] 3