Aggregate.dt: Aggregate attribute values throughout the entire tree...

Description Usage Arguments Examples

View source: R/Aggregate.dt.R

Description

This function aggregates multiple attribute variables from children nodes to their corresponding parent node simultaneously using a specific function

Usage

1
2
3
4
5
6
Aggregate.dt(
  tree,
  ...,
  aggfun,
  traversal = c("pre-order", "post-order", "in-order", "level", "ancestor")
)

Arguments

tree

the data tree object

...

the attribute variables to be aggregated for each node

aggfun

the aggregation function to be applied to each node's attributes

traversal

traversal order: any of 'pre-order' (the default), 'post-order', 'in-order', 'level', 'ancestor', or a custom function

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
## Not run: 
# create a data tree object
data(employee)
employee.tree = createTree(employee, "Employee Information",
                           c("Department", "JobRole", "EmployeeNumber"))

# aggregate the mean of monthly income for each node recursively
# to its corresponding parent node in post-order, upto the root node
Aggregate.dt(employee.tree, "MonthlyIncome",
             aggfun = function(x) mean(x, na.rm = TRUE),
             traversal = "post-order")

## End(Not run)

nzjessica/treevis documentation built on June 27, 2020, 1:20 a.m.