Matches two mcnodes by aligning groups, scenarios, or adding missing groups across different scenarios.
Arguments
- mcmodule
(mcmodule object). Module containing nodes.
- mc_name_x
(character). First mcnode name.
- mc_name_y
(character). Second mcnode name.
- keys_names
(character vector, optional). Column names for matching. Default: NULL.
- match_scenario
(logical). If TRUE, scenario_id is used for alignment (default behavior). If FALSE, scenario_id is treated as a regular key, enabling cross-scenario matching. Default: TRUE.
Details
Matching proceeds in order:
Group matching — align nodes with same scenarios but different group order
Scenario matching — align nodes with same groups but different scenarios
Null matching — add missing groups across different scenarios
Examples
test_module <- list(
node_list = list(
node_x = list(
mcnode = mcstoc(runif,
min = mcdata(c(1, 2, 3), type = "0", nvariates = 3),
max = mcdata(c(2, 3, 4), type = "0", nvariates = 3),
nvariates = 3
),
data_name = "data_x",
keys = c("category")
),
node_y = list(
mcnode = mcstoc(runif,
min = mcdata(c(5, 6, 7), type = "0", nvariates = 3),
max = mcdata(c(6, 7, 8), type = "0", nvariates = 3),
nvariates = 3
),
data_name = "data_y",
keys = c("category")
)
),
data = list(
data_x = data.frame(
category = c("A", "B", "C"),
scenario_id = c("0", "0", "0")
),
data_y = data.frame(
category = c("B", "B", "B"),
scenario_id = c("0", "1", "2")
)
)
)
result <- mc_match(test_module, "node_x", "node_y")
#> Group by: category
#> node_x prev dim: [1001, 1, 3], new dim: [1001, 1, 5], 0 null matches
#> node_y prev dim: [1001, 1, 3], new dim: [1001, 1, 5], 2 null matches
