oak (version 0.2.1)

flatten: Flatten a tree

Description

The function flatten returns all the nodes that compose a given tree.

Usage

flatten(.tree)

# S3 method for rtree flatten(.tree)

Arguments

.tree

A tree to be flattened.

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)))
flatten(tr2)

## Unrooted tree
(tr3 = r_(s = list(tr2, c_("Grand-Mother", "Father", "Son"))))
flatten(tr3)

# }

Run the code above in your browser using DataCamp Workspace