Skip to contents

Matches datasets by group and preserves baseline scenarios (scenario_id = 0) when scenarios differ between them.

Usage

wif_match(x, y, by = NULL)

Arguments

x

(data frame). First dataset to match.

y

(data frame). Second dataset to match.

by

(character vector, optional). Grouping column name(s) to match on. If NULL, auto-detected from column names. Default: NULL.

Value

A list containing matched datasets with aligned scenario IDs. Element 1: matched version of x. Element 2: matched version of y.

Examples

x <- data.frame(
  category = c("a", "b", "a", "b"),
  scenario_id = c(0, 0, 1, 1),
  value = 1:4
)

y <- data.frame(
  category = c("a", "b", "a", "b"),
  scenario_id = c(0, 0, 2, 2),
  value = 5:8
)

# Automatic matching
result <- wif_match(x, y)
#> Group by: category
#> From 4 rows (2 groups, 2 scenarios) and 4 rows (2 groups, 2 scenarios), to 6 rows (2 groups, 3 scenarios)