| name | r-data-validation |
| description | Build auditable R data-validation pipelines with pointblank, branching-aware missingness rules, row-level extracts, and testable logic checks. Use for data-quality validators and business or clinical rule screening. |
| argument-hint | ["validation target"] |
R Data Validation
Turn data-quality rules into explicit, reviewable validation plans that separate missingness, business logic, and downstream action.
Quick start
- Read
references/pointblank-workflow.md.
- Write down the validation contract before coding: required fields, branch-open fields, range rules, and cross-field logic rules.
- Build one
pointblank agent per source table.
- Add missingness rules first, then logic and consistency rules.
- Run
interrogate(extract_failed = TRUE) and return the interrogated agent or the failed-row extracts.
- Add targeted
testthat coverage for happy path, branch-open failure, branch-closed pass, and invalid input.
Workflow
1. Define the validation contract
- Separate always-required fields from branch-dependent fields.
- Decide which failures should block analysis, which should warn, and which should feed a correction queue.
- Give every rule a stable
step_id so failed rows remain traceable.
2. Build missingness checks first
- Use
col_vals_not_null() for globally required fields.
- Use
preconditions = to subset to branch-open rows before checking child fields.
- Keep missingness rules independent from logic rules so failures stay interpretable.
3. Add logic and integrity checks second
- Use type-specific validators when possible.
- Use
col_vals_expr(~ ...) for cross-field logic.
- Decide
na_pass intentionally based on whether missingness is already handled elsewhere.
4. Interrogate and extract failures
- Run
interrogate(extract_failed = TRUE).
- Review
all_passed(agent), agent[["validation_set"]], and get_data_extracts(agent).
- Return the interrogated agent when downstream code needs both the rule summary and row-level extracts.
5. Keep validator functions small
- Accept one data frame unless the task truly needs a broader interface.
- Return one stable validation object.
- Keep helper logic deterministic so test assertions remain durable.
Coordination notes
- Reach for
/r-stats when the issue is mainly statistical cleaning or analysis design rather than validation.
- Reach for
/r-advanced when repeated repo history shows the same validation or coercion failures coming back.
Resource
references/pointblank-workflow.md