Learn R Programming

GE (version 0.1.1)

node_insert: Insert Nodes into a Tree

Description

Scan the tree and insert nodes before the first non-root node having the name specified. This function is based on the package data.tree and has side-effects. It modifies the tree given by the argument (see the package data.tree).

Usage

node_insert(tree, node.name, ...)

Arguments

tree

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

node.name

a character string specifying the name of a node. Some nodes will be inserted before it.

...

some Node objects or character strings. A character string will be treated as the name of a new node to be created. Those nodes will be inserted into the tree.

Value

Invisibly returns the parent node of those new nodes.

Examples

Run this code
# NOT RUN {
dst.firm <- node_set(
  "output", NA,
  "prod1",
  "prod2"
)
plot(dst.firm)

dst.VA <- node_set(
  "VA", NA,
  "lab",
  "cap"
)

node_insert(dst.firm, "prod1", dst.VA, "prod3")
plot(dst.firm)
# }

Run the code above in your browser using DataLab