Learn R Programming

oak (version 0.2.3)

siblings: Siblings of a node

Description

The function siblings returns the siblings of a node in a given tree.

Usage

siblings(.node, .tree, include_node = FALSE)

# S3 method for rtree siblings(.node, .tree, include_node = FALSE)

Arguments

.node

node or character. The node or label of the node considered.

.tree

A tree.

include_node

logical. If FALSE (the default), the node .node is not included to the list of siblings.

Value

A (possibly empty) list of nodes.

Examples

Run this code
# NOT RUN {
## Rooted tree
(tr0 = c_("Bob", "Carl", "Daniel"))
(tr1 = c_("Bill", "Caroline", "Dimitri", "Enoc"))
(tr2 = r_("Alice", s = list(tr0, tr1)))
siblings("Bob", tr2)

## Unrooted tree
(tr3 = r_(s = list(tr2, c_("Grand-Mother", "Father", "Son"))))
siblings("Alice", tr3) # note that in 'tr3', Alice and Grand-Mother are not siblings

# }

Run the code above in your browser using DataLab