oak (version 0.2.1)

rtree: Tree constructor

Description

The function rtree creates an 'rtree' (recursive tree) object.

Usage

rtree(label = NULL, subtrees = list(), ...)

r_(label = NULL, subtrees = list(), ...)

empty_tree()

# S3 method for rtree is.empty(x)

Arguments

label

character. The label of the root of the tree created. If label=NULL, the tree created is unrooted. If label=NULL and subtrees=list(), the tree created is the empty tree.

subtrees

A (possibly empty) list of rtree objects. These rtrees must be rooted, otherwise an error is thrown.

...

Additional arguments to be passed as attributes to each node of the tree.

x

A tree.

Value

An rtree object.

Examples

Run this code
# NOT RUN {
## Chains
(tr0 = c_("Bob", "Carl", "Daniel"))
(tr1 = c_("Bill", "Caroline", "Dimitri", "Enoc"))

## Rooted tree
(tr2 = r_("Alice", s = list(tr0, tr1)))

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

Run the code above in your browser using DataCamp Workspace