Saves the result of check_study() to CSV or Excel, so findings can be
shared with people who don't use R, tracked in a spreadsheet, or attached
to a data-review document.
Arguments
- result
A result from
check_dataset()orcheck_study().- path
Output file path. The extension decides the format:
.xlsxfor Excel,.csv(or anything else) for CSV.- tracking
Add the empty
Status/Owner/Notescolumns.TRUEby default; setFALSEfor a file you intend to read back into R.
Value
The paths actually written, invisibly. One element for Excel (a
single workbook). For CSV, one path per file written: the findings, plus
siblings for skipped and about, plus one for truncated when any rule
flagged more records than were kept.
Details
Both tables are always written, never just the findings. A short findings table can mean clean data, or it can mean many rules were skipped, and those two situations look identical if the skipped table is dropped:
Excel (
.xlsx) - one workbook with a sheet per table:findings,skipped,about, andtruncatedwhen any rule matched more records than were kept.CSV (
.csv) - one file per table, since CSV has no notion of sheets. Findings go topath; the others go to sibling files with a suffix before the extension, soissues.csvgivesissues_skipped.csvandissues_about.csv.
Excel output needs the writexl package. It is a Suggests, so if it
isn't installed you get a clear message telling you to install it or use
.csv instead, rather than a failure part-way through writing.
Columns for tracking
Three empty columns are added to the findings - Status, Owner and
Notes - for you to fill in by hand once the file is open. They exist so a
finding you have looked at and decided not to act on ("expected, see
protocol deviation log") can be recorded next to the finding itself, rather
than in a separate document nobody reads.
Examples
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"))
study <- read_study(dir)
result <- check_study(study)
out <- file.path(dir, "findings.csv")
written <- write_findings(result, out)
basename(written)
#> [1] "findings.csv" "findings_skipped.csv" "findings_about.csv"
unlink(dir, recursive = TRUE)
