Get an attribute from a Node.
GetAttribute(
node,
attribute,
...,
format = FALSE,
inheritFromAncestors = FALSE,
nullAsNa = TRUE
)
The Node
from which the attribute
should be fetched.
determines what is collected. The attribute
can be
a.) the name of a field or a property/active of each Node
in the tree, e.g. acme$Get("p")
or acme$Get("position")
b.) the name of a method of each Node
in the tree, e.g. acme$Get("levelZeroBased")
, where e.g. acme$levelZeroBased <- function() acme$level - 1
c.) a function, whose first argument must be a Node
e.g. acme$Get(function(node) node$cost * node$p)
in case the attribute
is a function or a method, the ellipsis is passed to it as additional arguments.
if FALSE
(the default), no formatting is being used. If TRUE
, then the first formatter (if any) found along the ancestor path is being used for formatting
(see SetFormat
). If format
is a function, then the collected value is passed to that function, and the result is returned.
if TRUE
, then the path above a Node
is searched to get the attribute
in case it is NULL.
If TRUE (the default), then NULL is returned as NA. Otherwise it is returned as NULL.
data(acme)
GetAttribute(acme$IT$Outsource, "cost")
Run the code above in your browser using DataLab