## ----include = FALSE---------------------------------------------------------- knitr::opts_chunk$set(collapse = TRUE, comment = "#>") ## ----setup-------------------------------------------------------------------- library(coreval) ## ----one-dataset-------------------------------------------------------------- ae <- data.frame( STUDYID = "DEMO", DOMAIN = "AE", USUBJID = c("S1", "S1", "S2"), AESEQ = c(1, 2, 1), AETERM = c("Headache", "Nausea", "Rash"), AESTDTC = c("2024-01-10", "2024-02-30", "2024-01-12"), AEENDTC = c("2024-01-12", "2024-02-01", "") ) result <- check_dataset(ae) result ## ----one-dataset-date--------------------------------------------------------- result$findings[result$findings$Value == "2024-02-30", ] ## ----one-dataset-file, eval = FALSE------------------------------------------- # result <- check_dataset("ae.xpt") ## ----one-dataset-skips-------------------------------------------------------- cross <- result$skipped[grepl("was not supplied", result$skipped$reason), ] nrow(cross) head(unique(cross$reason), 3) ## ----ct, eval = FALSE--------------------------------------------------------- # check_study(dir, ct_package = "sdtmct-2026-03-27") # list_ct_packages("sdtm") # every published version, pick the one you declare ## ----build-study-------------------------------------------------------------- dir <- tempfile("coreval_demo_") dir.create(dir) dm <- data.frame( STUDYID = "DEMO", DOMAIN = "DM", USUBJID = c("S1", "S2", "S3"), RFSTDTC = c("2024-01-05", "2024-01-06", ""), AGE = c(34, 61, 47), AGEU = c("YEARS", "YEARS", ""), SEX = c("M", "F", "F") ) haven::write_xpt(dm, file.path(dir, "dm.xpt")) haven::write_xpt(ae, file.path(dir, "ae.xpt")) ## ----check-------------------------------------------------------------------- study_result <- check_study(dir) ## ----read--------------------------------------------------------------------- study <- read_study(dir) names(study$datasets) ## ----findings-head------------------------------------------------------------ head(study_result$findings) ## ----findings-filter---------------------------------------------------------- f <- study_result$findings head(f[f$Dataset == "DM", ]) sort(table(f$rule_id), decreasing = TRUE)[1:3] ## ----filter-findings---------------------------------------------------------- worst <- filter_findings(study_result, triage = "wrong value") nrow(worst$findings) summary(worst) ## ----skipped------------------------------------------------------------------ head(study_result$skipped) ## ----export, eval = FALSE----------------------------------------------------- # write_findings(study_result, "issues.xlsx") # one workbook, a sheet per table # write_findings(study_result, "issues.csv") # issues.csv + _skipped + _about ## ----rules-------------------------------------------------------------------- rules <- list_rules() nrow(rules) table(rules$source) attr(rules, "rules_version") ## ----rules-for-domain--------------------------------------------------------- nrow(list_rules(domain = "AE")) rule <- list_rules(id = "CORE-000547") rule$issue ## ----rule-ids----------------------------------------------------------------- rule$legacy_ids ## ----narrow, eval = FALSE----------------------------------------------------- # result <- check_dataset(dm, standard = "SDTMIG", version = "3.4") ## ----usdm, eval = FALSE------------------------------------------------------- # result <- check_study("path/to/usdm") ## ----cleanup, include = FALSE------------------------------------------------- unlink(dir, recursive = TRUE)