which_node: Which node id is common to a group of labels

View source: R/noded_with_condition.R

which_nodeR Documentation

Which node id is common to a group of labels

Description

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.

Usage

which_node(dend, labels, max_id = TRUE, ...)

Arguments

dend

a dendrogram dend

labels

a character vector of labels from the tree

max_id

logical (TRUE) - if to return only the max id

...

ignored.

Value

An integer with the id(s) of the nodes which includes all of the labels.

See Also

noded_with_condition, branches_attr_by_clusters, nnodes, branches_attr_by_labels, get_nodes_attr which.edge

Examples


dend <- iris[1:10, -5] %>%
  dist() %>%
  hclust() %>%
  as.dendrogram() %>%
  set("labels", 1:10)
dend %>% plot()

which_node(dend, c(1, 2), max_id = FALSE)
which_node(dend, c(2, 3), max_id = FALSE)
which_node(dend, c(2, 3))

dend %>% plot()
the_h <- get_nodes_attr(dend, "height", which_node(dend, c(4, 6)))
the_h
abline(h = the_h, lty = 2, col = 2)
get_nodes_attr(dend, "height", which_node(dend, c(4, 6)))
get_nodes_attr(dend, "members", which_node(dend, c(4, 6)))

dendextend documentation built on Oct. 13, 2024, 1:06 a.m.