Learn R Programming

GE (version 0.1.1)

node_new: Create a Tree

Description

Create a tree by the node_set function.

Usage

node_new(root.name, ...)

Arguments

root.name

a character string specifying the name of the root node.

...

attribute names and values (e.g. alpha=1). The parameter name of a value will be treated as the name of an attribute. A value without a parameter name will be treated as a child node or the name of a child node. If the class of the value is Node, it will be added as a child. If the class of the value is character, a child node will be created with the value as the name.

Value

A tree (i.e. a Node object).

Examples

Run this code
# NOT RUN {
#### create a tree
dst1 <- node_new("firm1")
print(dst1)

## create a tree with children
dst <- node_new(
  "firm",
  "lab", "cap", dst1
)
print(dst)

#### create a tree with attributes
dst <- node_new("firm",
  type = "CD", alpha = 1, beta = c(0.5, 0.5)
)
node_print(dst)

#### create a tree with attributes and children
dst <- node_new("firm",
  type = "CD", alpha = 1, beta = c(0.5, 0.5),
  "lab", "cap"
)
node_print(dst)

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab