Learn R Programming

data.tree (version 1.1.0)

Do: Executes a function on a set of nodes

Description

Executes a function on a set of nodes

Usage

# OO-style:
# node$Do(fun, 
#         ..., 
#         traversal = c("pre-order", "post-order", "in-order", "level", "ancestor"), 
#         pruneFun = NULL, 
#         filterFun = NULL)
         
# traditional:
Do(nodes, fun, ...)

Arguments

nodes

The nodes on which to perform the Get (typically obtained via Traverse)

fun

the function to execute. The function is expected to be either a Method, or to take a Node as its first argument

...

any additional parameters to be passed on to fun

See Also

Node

Get

Set

Traverse

Examples

Run this code
data(acme)
traversal <- Traverse(acme)
Do(traversal, function(node) node$expectedCost <- node$p * node$cost)
print(acme, "expectedCost")

Run the code above in your browser using DataLab