From a6b4960d936ff80f434030e31e186877cb2bcb06 Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 29 Dec 2021 12:07:47 -0600 Subject: [PATCH] early version of Rmd ref #5 --- for-developers/sandbox/report-1.Rmd | 166 ++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 for-developers/sandbox/report-1.Rmd diff --git a/for-developers/sandbox/report-1.Rmd b/for-developers/sandbox/report-1.Rmd new file mode 100644 index 0000000..fc77f76 --- /dev/null +++ b/for-developers/sandbox/report-1.Rmd @@ -0,0 +1,166 @@ +--- +title: REDCapR Validator Example 1 # Change this value for new validators. +date: "Date: `r Sys.time()`" +output: + html_document: + keep_md: yes + toc: yes + toc_float: true + number_sections: true + # css: ../analysis/common/styles-1.css +--- + + + +```{r, echo=F, message=F} +# cat("Working directory: ", getwd()) +library(knitr) +# Change this value for new validators. +# opts_knit$set(root.dir='../') #Don't combine this call with any other chunk -especially one that uses file paths. +``` + + +```{r set-options, echo=F} +# cat("Working directory: ", getwd()) +report_render_start_time <- Sys.time() +opts_chunk$set( + results = 'show', + warning = FALSE, + comment = NA, + tidy = FALSE, + fig.width = 6.5, + fig.height = 4, + fig.path = 'figure-png/' +) +# dpi = 400, +# out.width = "650px", #This affects only the markdown, not the underlying png file. The height will be scaled appropriately. + +echo_chunks <- FALSE +options(width=100) #So the output is 25% wider than the default. + +# Change this value for new validators. +# read_chunk("./analysis/validator-1.R") #This allows knitr to call chunks tagged in the underlying *.R file. +``` + + +```{r load-packages, echo=echo_chunks, message=FALSE, warning=FALSE} +requireNamespace("dplyr") +requireNamespace("DT") +``` + + +```{r declare-globals, echo=echo_chunks, results='show', message=FALSE} +``` + + +```{r, echo=echo_chunks, message=FALSE} + #Put presentation-specific code in here. It doesn't call a chunk in the codebehind file. +``` + + +```{r load-data, echo=echo_chunks, results='show', message=FALSE} +``` + + +```{r tweak-data, echo=echo_chunks, results='show', message=TRUE} +``` + +```{r groom-rules, echo=echo_chunks, results='show', message=TRUE} +``` + +```{r groom-smells, echo=echo_chunks, results='show', message=TRUE} +``` + +Set Up {.tabset .tabset-fade} +============================= + +Instructions +----------------------------- + +1. Work through each line in the table to discover & correct entry mistakes in the database. Be aware that a single mistake may manifest in multiple rows; fixing one value may clear several rows. +1. Click the `record id` value in a row to be taken to the participant's Event Grid in REDCap (*i.e.*, the 'stop light page'). +1. Double-check that your manual corrections in REDCap are reflected in `r checks$path_output_rule`. Be careful not to move this file to somewhere unsafe. +1. To help discover the dataflow and problematic location, use the + * project's [codebook](`r checks$redcap_codebook`) in REDCap, + * [validator-1-arch](`r checks$github_link_arch`) file, and + * [validator-1](`r checks$github_link_report`) report. +1. If you create a new rule or smell check, make sure the error message won't reveal any PHI. + +Execute Rules +----------------------------- +```{r execute-rules, echo=echo_chunks, message=TRUE, results='asis'} +``` + +Execute Smells +----------------------------- +```{r execute-smells, echo=echo_chunks, message=TRUE, results='asis'} +``` + +Inactive Rules +----------------------------- + +`r nrow(ds_rule_inactive)` rules are defined, but disabled for this report: + +```{r echo=echo_chunks, results='asis'} +# glue::collapse(paste0("1. ", ds_rule_inactive$check_name), sep="; \n", last=", and \n") +ds_rule_inactive |> + glue::glue_data("1. {check_name};") +``` + +Inactive Smells +----------------------------- + +`r nrow(ds_smell_inactive)` smells are defined, but disabled for this report: + +```{r echo=echo_chunks, results='asis'} +ds_smell_inactive |> + glue::glue_data("1. {check_name};") +# if( nrow(ds_smell_inactive) == 0L ) { +# cat("* *no smells are disabled*.") +# } else { +# glue::collapse(paste0("1. ", ds_smell_inactive$smell_name), sep="; \n", last=", and \n") +# } +``` + +Rules {.tabset .tabset-fade} +============================= + +A *rule* is very exact. Each record is examined, and determined if it passes each specific rule. + +Rule Detail +----------------------------- +```{r table-rule-detail, echo=echo_chunks, message=TRUE} +``` + +Rule Summary +----------------------------- +```{r table-rule-summary, echo=echo_chunks, message=TRUE} +``` + +Smells {.tabset .tabset-fade} +============================= + +A *smell* test won't validate a given record (like the rules above), but it will make sure the dataset overall smells correct. + +Smell Summary +----------------------------- +```{r table-smell-summary, echo=echo_chunks, message=TRUE} +``` + +Termination {.tabset .tabset-fade} +============================= + +### Save To Disk + +```{r verify-values, echo=echo_chunks, message=TRUE} +``` + +```{r specify-columns-to-upload, echo=echo_chunks, message=TRUE} +``` + +```{r save-to-disk, echo=echo_chunks, message=TRUE} +``` + + + +