# NOT RUN {
data(acme)
#Aggregate on a field
Aggregate(acme, "cost", sum)
#Aggregate using Get
print(acme, "cost", minCost = acme$Get(Aggregate, "cost", min))
#use Aggregate with caching:
acme$cost
acme$Do(function(x) Aggregate(x, "cost", sum, cacheAttribute = "cost"), traversal = "post-order")
acme$cost
#use Aggregate with a function:
acme$Do(function(x) x$expectedCost <- Aggregate(x,
function(x) x$cost * x$p,
sum)
, traversal = "post-order")
# }
Run the code above in your browser using DataLab