
Reconcile two sources under an explicit matching schema
Source:R/mrm_flagship.R
morie_mrm_reconcile.RdThe reconciliation step of the MRM: joins a primary and a secondary source on identifier keys, optionally tolerating bounded disagreement on numeric fields (e.g. dates recorded a day apart), and reports the match rate, the orphans on each side, and field-level conflicts among matched records.
Arguments
- primary, secondary
Data frames (or
morie_mrm_datasetobjects).- keys
Character vector of join-key column names present in both sources.
- compare
Optional character vector of shared columns to check for field-level conflicts among matched rows.
- numeric_tolerance
Absolute tolerance under which numeric disagreements in
comparecolumns are NOT conflicts (default 0).
Value
An object of class morie_mrm_reconciliation: list
with matched (merged data frame), unmatched_primary,
unmatched_secondary, conflicts (long data frame:
key, field, primary_value, secondary_value), match_rate,
schema.
Examples
a <- data.frame(id = 1:5, y = c(1, 2, 3, 4, 5))
b <- data.frame(id = c(1:4, 9), y = c(1, 2, 3.5, 4, 9))
r <- morie_mrm_reconcile(a, b, keys = "id", compare = "y")
r$match_rate
#> [1] 0.8
nrow(r$conflicts)
#> [1] 1