Learn R Programming

DCC (version 1.2.1)

dcc_detect: Run a rule set against data (Detect stage)

Description

Evaluates every check in a rule set and returns the combined findings table. Detection is pure and read-only: the same data and the same rule set always produce the same findings, and the input is never modified. Range checks report non-missing values that cannot be converted to numeric with code INVALID_NUMERIC; numeric bounds violations use OUT_OF_RANGE.

Usage

dcc_detect(x, rules, id_var = NULL)

Value

A dcc_findings table. If x is a dcc_data, the result carries a dcc_data attribute: the input container with a detect provenance record (rule file hash, findings count) appended.

Arguments

x

A dcc_data object or data.frame.

rules

A dcc_ruleset from dcc_rules.

id_var

Name of the record-id column, or NULL for row numbers.

Examples

Run this code
df <- data.frame(sid = c("S1", "S2"), score = c(50, 150))
f <- tempfile(fileext = ".yaml")
writeLines(c(
  "checks:",
  "  - id: R001",
  "    type: range",
  "    variable: score",
  "    min: 0",
  "    max: 100"
), f)
if (requireNamespace("yaml", quietly = TRUE)) {
  dcc_detect(df, dcc_rules(f), id_var = "sid")
}

Run the code above in your browser using DataLab