R/utils.R
diff_reports.Rd
This report will identify flagged records from an sdtmchecks report that are "new" and those that are "old" for a study. This will help quickly target newly emergent issues that may require a new query or investigation while indicating issues that were encountered from a prior report and may have already been queried.
This diff_reports()
function requires a newer and older set of results from
sdtmchecks::run_all_checks()
, which will generate a list of check results.
An added column "Status" is created with values of "NEW" and "OLD"
in the list of check results, flagging whether a given record that is present
in the new result (ie new_report
) is also present in the old result (ie old_report
).
It makes a difference which report is defined as "new" and "old".
This code only keeps results flagged in the new report and drops
old results not in the new report because they were presumably resolved.
diff_reports(old_report, new_report)
an older sdtmchecks list object as created by run_all_checks
a newer sdtmchecks list object as created by run_all_checks
list of sdtmchecks results based on new_report with Status indicator
Example programs for running data checks
report_to_xlsx()
,
run_all_checks()
,
run_check()
if (FALSE) {
## use the run_all_checks() function to generate list of check results
all_rec <- sdtmchecks::run_all_checks()
## save results as .RDS file
saveRDS(all_rec, file=paste0("saved_reports/sdtmchecks_", Sys.Date(), ".rds"))
## re-run the above steps on a different snapshot for the same study
## read in the previously created RDS files
old <- readRDS("saved_reports/sdtmchecks_01JAN2023.rds")
new <- readRDS("saved_reports/sdtmchecks_01FEB2023.rds")
## run sdtmchecks::diff_reports()
res <- diff_reports(old_report=old, new_report=new)
## output results as spreadsheet with sdtmchecks::report_to_xlsx()
report_to_xlsx(res, outfile=paste0("saved_reports/sdtmchecks_diff_",Sys.Date(),".xlsx"))
}