Cumulate {data.tree} | R Documentation |
Cumulate values among siblings
Description
For example, you can sum up values of siblings before
this Node
.
Usage
Cumulate(node, attribute, aggFun, ...)
Arguments
node |
The node on which we want to cumulate |
attribute |
determines what is collected. The
|
aggFun |
the aggregation function to be applied to the children's |
... |
any arguments to be passed on to attribute (in case it's a function) |
Examples
data(acme)
acme$Do(function(x) x$cost <- Aggregate(x, "cost", sum), traversal = "post-order")
acme$Do(function(x) x$cumCost <- Cumulate(x, "cost", sum))
print(acme, "cost", "cumCost")
[Package data.tree version 1.1.0 Index]