Learn R Programming

coreval (version 0.1.0)

write_findings: Write conformance findings to a file

Description

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.

Usage

write_findings(result, path, tracking = TRUE)

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.

Arguments

result

A result from check_dataset() or check_study().

path

Output file path. The extension decides the format: .xlsx for Excel, .csv (or anything else) for CSV.

tracking

Add the empty Status/Owner/Notes columns. TRUE by default; set FALSE for a file you intend to read back into R.

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.

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, two sheets: findings and skipped.

  • CSV (.csv) — two files, since CSV has no notion of sheets. Findings go to path; skipped rules go to a sibling file with _skipped before the extension (issues.csv gives issues_skipped.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.

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"))
study <- read_study(dir)
result <- check_study(study)

out <- file.path(dir, "findings.csv")
written <- write_findings(result, out)
basename(written)

unlink(dir, recursive = TRUE)

Run the code above in your browser using DataLab