Learn R Programming

DCC (version 1.2.1)

dcc_rules: Load a declarative rule set from a YAML file

Description

Rule files are YAML with embedded R expressions for complex logic. The top-level key checks holds a list of rules; each rule has id, type, an optional severity and dimension, and type-specific fields: range (variable, min/max), set (variable, values), expr (an R expression evaluated per record in a restricted environment), skip_logic (when {variable, equals} and then_not_required, marking skipped items as not administered for the missing-items detector), or a detector type (missing_items, straightlining, response_time, trap_items, score_anomaly) whose fields are passed to the matching detect_*() function.

Usage

dcc_rules(path)

Value

A dcc_ruleset object (list of normalized rules, with the source file and its MD5 hash attached for the audit trail).

Arguments

path

Path to the YAML rule file.

Examples

Run this code
f <- tempfile(fileext = ".yaml")
writeLines(c(
  "checks:",
  "  - id: R001",
  "    type: range",
  "    variable: score",
  "    min: 0",
  "    max: 100"
), f)
if (requireNamespace("yaml", quietly = TRUE)) {
  dcc_rules(f)
}

Run the code above in your browser using DataLab