| mc_summary | R Documentation |
Compute summary statistics for an mcnode object
mc_summary(
mcmodule = NULL,
mc_name = NULL,
keys_names = NULL,
data = NULL,
mcnode = NULL,
sep_keys = TRUE,
digits = NULL
)
mcmodule |
An mcmodule object containing the node to summarize |
mc_name |
Character string specifying the name of the mcnode in the module |
keys_names |
Vector of column names to use as keys for grouping (default: NULL) |
data |
Optional data frame containing the input data (default: NULL) |
mcnode |
Optional mcnode object to summarize directly (default: NULL) |
sep_keys |
Logical; if TRUE, keeps keys in separate columns (default: TRUE) |
digits |
Integer indicating number of significant digits for rounding (default: NULL) |
This function can be called in two ways:
By providing an mcmodule and mc_name
By providing data and mcnode directly
A data frame containing summary statistics with columns:
mc_name: Name of the mcnode
keys: Grouping variables (if sep_keys=FALSE) or individual key columns (if sep_keys=TRUE)
Summary statistics including:
mean: Average value
sd: Standard deviation
Various quantiles (2.5%, 25%, 50%, 75%, 97.5%)
# Use with mcmodule
summary_basic <- mc_summary(imports_mcmodule, "w_prev")
# Using custom keys and rounding
summary_custom <- mc_summary(imports_mcmodule, "w_prev",
keys_names = c("origin"),
digits = 3
)
# Use with data and mcnode
w_prev <- imports_mcmodule$node_list$w_prev$mcnode
summary_direct <- mc_summary(
data = imports_data,
mcnode = w_prev,
sep_keys = FALSE
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.