| agg_totals | R Documentation |
Combines node values across specified grouping variables using different aggregation methods. The aggregation method can be specified via agg_func parameter:
"prob": Combined probability assuming independence
"sum": Sum of values
"avg": Average of values
NULL: defaults to "sum" if mc_name ends in "_n", else defaults to "prob"
agg_totals(
mcmodule,
mc_name,
agg_keys = NULL,
agg_suffix = NULL,
prefix = NULL,
name = NULL,
summary = TRUE,
keep_variates = FALSE,
agg_func = NULL
)
mcmodule |
mcmodule object containing nodes and data |
mc_name |
name of node to aggregate |
agg_keys |
grouping variables for aggregation |
agg_suffix |
Suffix for aggregated node name (default: "agg") |
prefix |
Optional prefix for output node name - includes metadata as add_prefix() (default: NULL) |
name |
Custom name for output node (optional) |
summary |
whether to include summary statistics (default: TRUE) |
keep_variates |
whether to preserve individual values (default: FALSE) |
agg_func |
aggregation method ("prob", "sum", "avg", or NULL) |
mcmodule with new aggregated node added
imports_mcmodule <- agg_totals(
imports_mcmodule, "no_detect_a",
agg_keys = c("scenario_id", "pathogen")
)
print(imports_mcmodule$node_list$no_detect_a_agg$summary)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.