Skip to contents

Computes summary statistics for an mcnode object, including mean, standard deviation, and quantiles. Can be called with an mcmodule and node name, or directly with an mcnode and data frame.

Usage

mc_summary(
  mcmodule = NULL,
  mc_name = NULL,
  keys_names = NULL,
  data = NULL,
  mcnode = NULL,
  sep_keys = TRUE,
  digits = NULL
)

Arguments

mcmodule

(mcmodule object, optional). Module containing the node. Default: NULL.

mc_name

(character, optional). Name of the mcnode in the module.

keys_names

(character vector, optional). Column names for grouping. Default: NULL.

data

(data frame, optional). Input data frame. Default: NULL.

mcnode

(mcnode object, optional). mcnode to summarise directly. Default: NULL.

sep_keys

(logical). If TRUE, keep keys in separate columns; if FALSE, combine into single column. Default: TRUE.

digits

(integer, optional). Number of significant digits for rounding. Default: NULL.

Value

A data frame with summary statistics for each mcnode variate. Columns include:

  • mc_name: Node name.

  • Key columns (if sep_keys = TRUE) or single keys column (if FALSE).

  • mean: Average value.

  • sd: Standard deviation.

  • Quantile columns (2.5%, 25%, 50%, 75%, 97.5%).

Details

This function can be called in two ways:

  1. By providing an mcmodule and mc_name

  2. By providing data and mcnode directly

Examples

# 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
)