Re-hashes a set of named R objects and compares them against a previously
stored certification. Reports which outputs are unchanged ("ok"), have
changed ("drifted"), are present in the baseline but not supplied
("missing"), or are new outputs not in the baseline ("new").
Arguments
- outputs
A fully named list of current R objects – the same names used in the
certify()call being compared against.- against
character(1). The certification tag to compare against. Use"latest"(the default) to automatically select the most recently added certification.- file
character(1). Base path of the certification store. Default".reproducr"(reads.reproducr.rds).- tolerance
numeric(1). Numeric tolerance applied to hash comparison. When> 0, outputs whose hashes differ are also compared element-wise (for numeric vectors/matrices), and flagged as"ok"if the maximum absolute difference is withintolerance. Set to0for exact matching only. Default1e-10.
Value
Invisibly returns a data.frame of class
c("drift_report", "data.frame") with columns output, status
("ok", "drifted", "missing", "new"), max_delta, and note.
Also prints a summary to the console.
See also
certify() to create a baseline; list_certs() to see available
tags.
Examples
cert_file <- tempfile()
model <- lm(mpg ~ wt, data = mtcars)
certify(list(coefs = coef(model)), tag = "v1", file = cert_file)
#> reproducr: certified 1 output(s) [2026-06-10] under tag 'v1'
# Same outputs -- should report "ok"
result <- check_drift(list(coefs = coef(model)),
against = "v1", file = cert_file
)
#>
#> -- reproducr drift check vs 'v1' --
#>
#> Verdict : ALL OUTPUTS MATCH
#> OK : 1
#> Drifted : 0
#> Missing : 0
#> New : 0
#>
print(result)
#>
#> -- reproducr drift report --
#>
#> [OK] coefs
#>
# Different model -- should report "drifted"
model2 <- lm(mpg ~ hp, data = mtcars)
check_drift(list(coefs = coef(model2)),
against = "v1", file = cert_file
)
#>
#> -- reproducr drift check vs 'v1' --
#>
#> Verdict : DRIFT DETECTED
#> OK : 0
#> Drifted : 1
#> Missing : 0
#> New : 0
#>
#> Drifted outputs:
#> - coefs
#>