Skip to contents

Appends one named cross-check entry to a manifest, classifying it as PASS, DIFFER, or INFO, printing a formatted line to the console, and returning the updated manifest.

Usage

record(
  manifest,
  name,
  observed,
  expected,
  tol = 1e-04,
  group = "general",
  synthetic = FALSE
)

Arguments

manifest

A manifest as returned by make_manifest().

name

Unique name for this cross-check; used as the result key.

observed

The observed value (numeric or otherwise).

expected

The expected value to compare against.

tol

Numeric tolerance; a numeric pair within tol is PASS. Defaults to 0.0001.

group

Optional grouping label for the entry. Defaults to "general".

synthetic

Logical; if TRUE the entry is marked INFO because comparison against synthetic data is not meaningful.

Value

The updated manifest, returned so calls can be chained.

Examples

man <- make_manifest(list(project = "demo"), environment = FALSE)

# Within tolerance -> PASS.
man <- record(man, "mean_matches", observed = 1.0001, expected = 1,
              tol = 0.001)
#>   mean_matches                                 observed = 1.0001       expected = 1.0000       [PASS]
man$results$mean_matches$status      # "PASS"
#> [1] "PASS"

# Outside tolerance -> DIFFER.
man <- record(man, "sd_matches", observed = 2.5, expected = 2.0, tol = 0.01)
#>   sd_matches                                   observed = 2.5000       expected = 2.0000       [DIFFER]
man$results$sd_matches$status        # "DIFFER"
#> [1] "DIFFER"

# Synthetic data -> INFO (comparison not meaningful).
man <- record(man, "synthetic_row", observed = 5, expected = 5,
              synthetic = TRUE)
#>   synthetic_row                                observed = 5.0000       expected = 5.0000       [INFO]
man$results$synthetic_row$status     # "INFO"
#> [1] "INFO"

# Calls chain: record() returns the mutated manifest.
length(man$results)                  # 3
#> [1] 3