Skip to contents

[Experimental] Converts an mcnode to long format suitable for ggplot2 and tidyverse analysis. Each row represents one uncertainty iteration for one variate.

Usage

tidy_mcnode(
  mcmodule = NULL,
  mc_name = NULL,
  mcnode = NULL,
  data = NULL,
  keys_names = NULL,
  filter = NULL
)

Arguments

mcmodule

(mcmodule object, optional). Module containing the node.

mc_name

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

mcnode

(mcnode object, optional). mcnode to convert directly.

data

(data frame, optional). Input data; extracted from mcmodule if NULL. Default: NULL.

keys_names

(character vector, optional). Column names for grouping variates. If NULL, uses node keys from module or all available keys. Default: NULL.

filter

(expression, optional). Unquoted expression to filter variates (e.g., pathogen == "a" or origin == "nord"). Evaluated in context of keys data frame. Default: NULL.

Value

A long data frame with columns:

  • All key columns from keys_names.

  • variate: Variate index (data row number).

  • simulation: Uncertainty iteration index.

  • value: mcnode value for that combination.

Details

Call signatures:

  • tidy_mcnode(mcmodule, \"node_name\")

  • tidy_mcnode(mcnode = mcnode, data = data)

  • tidy_mcnode(mcmodule, mcnode = mcnode)

Examples

# Using mcmodule and node name
long_data <- tidy_mcnode(imports_mcmodule, "w_prev")

# Using with specific keys
long_data <- tidy_mcnode(imports_mcmodule, "w_prev",
  keys_names = "origin"
)

# Using mcnode and data directly
w_prev <- imports_mcmodule$node_list$w_prev$mcnode
long_data <- tidy_mcnode(mcnode = w_prev, data = imports_data)

# Filter variates
long_data <- tidy_mcnode(imports_mcmodule, "w_prev",
  filter = pathogen == "a"
)