Learn R Programming

coreval (version 0.1.0)

check_dataset: Check one dataset, without needing a study folder

Description

For when you are writing the code that builds a domain and want to know what is wrong with it right now. Give it the data frame you already have open, or the path to a single file.

Usage

check_dataset(
  x,
  domain = NULL,
  standard = NULL,
  version = NULL,
  use_case = NULL,
  max_records = 1000,
  include_deprecated = FALSE
)

Value

list(findings, skipped, truncated) - the same shape check_study() returns, so write_findings() works on it unchanged.

Arguments

x

A data frame (or data.table::data.table()), or the path to one .xpt, .sas7bdat or .csv file.

domain

Two-letter domain code, e.g. "AE". Left as NULL, coreval takes it from your DOMAIN column, or the file name if there isn't one - so ae1.xpt from a split dataset is still checked as AE. Set it yourself if that guess is wrong.

standard

The standard the data follows, e.g. "SDTMIG" or "SENDIG". Rules are scoped to it, which is usually what you want - a SENDIG rule has nothing to say about an SDTM study.

It is not free, though, and CDISC's coverage is uneven. The general "dates must be valid ISO 8601" rule (CORE-000547) is published for SENDIG and TIG but not for SDTMIG, whose only equivalents are TSVAL-specific or deprecated. So standard = "SDTMIG" genuinely stops a malformed RFSTDTC being reported. The report says how many rules were set aside; leave standard unset to see everything.

version

The standard's version, e.g. "3-4".

use_case

Optional use case (e.g. "INDH"), as in list_rules().

max_records

Most records to keep per rule, default 1000. A rule that flags every row of a large dataset would otherwise produce more findings than anyone can read or Excel can hold. The true count is kept in truncated. 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.

What it cannot check on its own

Plenty of CDISC rules compare one dataset against another - an adverse event date against the subject's reference dates in DM, a visit against the trial design. Hand over a single dataset and those questions cannot be answered.

coreval does not guess. Those rules are skipped, and $skipped names the dataset each one wanted. Running them anyway would compare your data against columns that are not there and report problems that do not exist.

Most rules still run - across AE, DM, LB and VS, 76-84% of the applicable ones work on a single dataset. But the ones that cannot are the cross-dataset checks, which are often the ones that matter.

So a short $findings table here does not mean the data is clean. It is a quick first pass, not a verdict. Run check_study() on the whole folder before drawing conclusions.

See Also

check_study() to check a whole study folder.

Examples

Run this code
ae <- data.frame(
  STUDYID = "S1", DOMAIN = "AE", USUBJID = c("01", "01"),
  AESEQ = c(1, 2), AETERM = c("Headache", "Rash"),
  AESTDTC = c("2024-01-10", "2024-02-30") # 30 February is not a date
)
result <- check_dataset(ae)
result$findings[result$findings$Value == "2024-02-30", ]

# Always look at what could not run:
nrow(result$skipped)

Run the code above in your browser using DataLab