Learn R Programming

DCC (version 1.2.1)

dcc_run: Run a cleaning workflow with one command

Description

The survey-staff entry point: orchestrates the Detect -> Execute -> Report pipeline from a dcc_config or strict plan and writes a fixed output layout. Preview is the default, so the safe path requires no extra care, and the raw input file is never modified in any mode. Files are written to a same-parent staging directory and published atomically. Existing output directories are never overwritten; failed runs publish a diagnostic .failed-<run_id> directory and raise dcc_run_error. A renderer failure publishes cleaning evidence under .partial-<run_id> and records the failed audience without claiming full success.

Usage

dcc_run(data, config = NULL, output_dir,
  mode = c("preview", "execute", "verify", "rerun"), id_var = NULL,
  plan = NULL)

Value

A dcc_run object with mode, terminal status, config, written paths (via dcc_run_files), normalized report model, and structured run manifest.

Arguments

data

A data file path, a dcc_data, or a data.frame (or a manifest path in "rerun" mode).

config

Optional dcc_config from dcc_config. Supply this or plan, not both.

output_dir

Directory for the fixed output layout (created if needed). Required and never defaulted: the caller chooses every location DCC writes to.

mode

One of "preview" (default), "execute", "verify", "rerun".

id_var

Record-id column; defaults to the config's id_var.

plan

Optional strict .xlsx/.json plan path or dcc_plan.

Details

Modes: "preview" detects and reports only (no data change, no cleaned-data.csv); "execute" applies the configured actions and writes the cleaned data, audit log, and manifest; "verify" is like execute with a reconciliation summary; "rerun" reproduces a previous run from its manifest.yaml; pass the manifest path as data and use a new output_dir.

Output layout under output_dir: cleaned-data.csv (execute/verify), findings.xlsx (or findings.csv without the writexl package), audit-log.csv (execute/verify), management-report.html, audit-report.html, manifest.yaml (execute/verify), run-summary.txt, run-manifest.json, and selected staff/, statistical/, and machine/ audience directories.

See Also

dcc_config, dcc_run_files, dcc_doctor.

Examples

Run this code
rf <- tempfile(fileext = ".yaml")
writeLines(c("checks:", "  - id: R001", "    type: range",
             "    variable: score", "    min: 0", "    max: 100"), rf)
csv <- tempfile(fileext = ".csv")
writeLines(c("sid,score", "S1,90", "S2,150"), csv)
if (requireNamespace("yaml", quietly = TRUE)) {
  cfg <- dcc_config(dcc_rules(rf), actions = list(R001 = "set_na"),
                    id_var = "sid")
  run <- dcc_run(csv, cfg, tempfile("dcc-out"), mode = "preview")
  dcc_run_files(run)
}

Run the code above in your browser using DataLab