node_replace {GE}R Documentation

Replace a Node of a Tree

Description

Scan the tree and replace 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_replace(tree, node.name, ...)

Arguments

tree

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

node.name

a character string specifying the name of the node to be pruned off.

...

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 added to the tree.

Value

Invisibly returns the parent node of those new nodes.

Examples


dst.firm <- node_new(
  "output",
  "prod1", "prod2"
)
plot(dst.firm)

dst.VA <- node_new(
  "VA",
  "lab", "cap"
)

node_replace(
  dst.firm, "prod2",
  dst.VA, "prod3"
)
plot(dst.firm)

node_replace(
  dst.firm, "lab",
  "labor"
)
plot(dst.firm)

node_replace(
  dst.firm, "VA",
  "prod2"
)
plot(dst.firm)



[Package GE version 0.4.4 Index]