Learn R Programming

coreval (version 0.1.0)

check_study: Check a whole study against CDISC Open Rules

Description

Runs every rule that applies to every dataset in the study, including the ones that compare datasets against each other. Use this once the datasets exist as files; to check a single dataset while you are still writing the code that builds it, see check_dataset().

Usage

check_study(
  study,
  use_case = NULL,
  max_records = 1000,
  include_deprecated = FALSE
)

Value

Three tables:

  • findings - what is wrong. One row per problem, with Dataset, Record, Variable, Value, the issue in words, and its triage. Not in dataset under Value means the rule wanted a variable you do not have, which is usually the finding itself.

  • skipped - what could not be checked, with a reason for each. Read this one: an empty findings table can mean clean data or rules that never ran, and they look identical otherwise.

  • truncated - rules that flagged more records than max_records kept, with how many they really found.

Arguments

study

A study folder path, or a study object from read_study(). Passing the path is the usual way; reading first is only worth it when you want to check the same large study more than once without re-reading it, or to look at what was parsed.

use_case

Optional use case (e.g. "INDH") to further filter which rules apply, as in list_rules().

max_records

Most records to keep per rule, default 1000. A rule can flag every row - a missing EPOCH on a 200 000-row LB is 200 000 identical findings, more than Excel can hold. The true count is kept in truncated and the report shows it, so nothing is under-reported. Use Inf for every record.

include_deprecated

Also run rules CDISC has deprecated. FALSE by default: a deprecated rule has a published replacement, so running both reports the same defect twice.

Details

Findings come back one row per (dataset, record, variable), pointing at the exact spot. Some rules ask about a dataset as a whole rather than a particular row - those leave Record blank. A few ask about the study as a whole, such as "is DM present at all?"; those are answered once and reported under Dataset = "STUDY" rather than repeated for every domain.

Rules comparing against a define.xml do run, as long as the study has one and the xml2 package is installed. Without both, they are skipped with a reason instead of being run against columns that are not there, which would report problems that do not exist. The same goes for any rule needing an operator or join coreval does not implement yet.

Examples

Run this code
dir <- tempfile("coreval_study_")
dir.create(dir)
haven::write_xpt(data.frame(USUBJID = c("1", "2"), AGE = c(30, 65)), file.path(dir, "dm.xpt"))

result <- check_study(dir)
result$findings
unlink(dir, recursive = TRUE)

Run the code above in your browser using DataLab