powered by
For example, you can sum up values of siblings before this Node.
Node
Cumulate(node, attribute, aggFun, cacheAttribute = NULL, ...)
The node on which we want to cumulate
determines what is collected. The attribute can be
attribute
a.) the name of a field of each Node in the tree
b.) the name of a method of each Node in the tree
c.) a function, whose first argument must be a Node
the aggregation function to be applied to the children's attributes
attributes
A field into which the results should be cached. Speeds up calculation.
any arguments to be passed on to attribute (in case it's a function)
# NOT RUN { data(acme) acme$Do(function(x) Aggregate(x, "cost", sum, "cost"), traversal = "post-order") acme$Do(function(x) Cumulate(x, "cost", sum, "cumCost")) print(acme, "cost", "cumCost") # }
Run the code above in your browser using DataLab