Skip to content

Commit

Permalink
simplify rmd a little
Browse files Browse the repository at this point in the history
There are a lot of options useful in [RAnalysisSkeleton](https://github.com/wibeasley/RAnalysisSkeleton/tree/main/analysis) that are unnecessary here.

ref #5
  • Loading branch information
wibeasley committed Dec 30, 2021
1 parent 76c6b4c commit 18283b4
Show file tree
Hide file tree
Showing 3 changed files with 764 additions and 29 deletions.
40 changes: 11 additions & 29 deletions inst/report-templates/rmarkdown-1/report-1.Rmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: REDCapR Validator Example 1 # Change this value for new validators.
title: Trawler Report
date: "Date: `r Sys.time()`"
output:
html_document:
Expand All @@ -12,46 +12,28 @@ params:
path_checks: "not-set"
---


<!-- Set the working directory to the repository's base directory; this assumes the report is nested inside of three directories.-->
```{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.
```

<!-- Set the report-wide options, and point to the external code file. -->
```{r set-options, echo=F}
library(knitr)
# 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/'
warning = TRUE
)
# 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.
```

<!-- Load 'sourced' R files. Suppress the output when loading packages. -->
```{r load-packages, echo=echo_chunks, message=FALSE, warning=FALSE}
<!-- Suppress the output when loading packages. -->
```{r load-packages, echo = echo_chunks, message = FALSE}
requireNamespace("dplyr")
requireNamespace("DT")
```

<!-- Load any global functions and variables declared in the R file. Suppress the output. -->
```{r declare-globals, echo=echo_chunks, results='show', message=FALSE}
```{r declare-globals, echo = echo_chunks}
path_checks <-
if (params$path_checks == "not-set") {
system.file("derived/biochemical.rds", package = "trawler")
Expand All @@ -64,12 +46,12 @@ checkmate::assert_file_exists(path_checks, extension = "rds")
```

<!-- Load the datasets. -->
```{r load-data, echo=echo_chunks, results='show', message=FALSE}
checks <- readRDS(path_checks)
```{r load-data, echo = echo_chunks}
checks <- base::readRDS(path_checks)
```

<!-- Tweak the datasets. -->
```{r tweak-data, echo=echo_chunks, results='show', message=TRUE}
```{r tweak-data, echo = echo_chunks}
```


Expand All @@ -80,7 +62,7 @@ A *smell* test won't validate a specific record (like the rules below), but it w

Smell Summary
-----------------------------
```{r table-smell-summary, echo=echo_chunks, message=TRUE}
```{r table-smell-summary, echo = echo_chunks}
palette_summary <- list(warm = "#fde0ef", hot = "#f1b6da", header = "#555") #http://colrd.com/palette/18841/
ds_smell_result_pretty <-
Expand Down
606 changes: 606 additions & 0 deletions inst/report-templates/rmarkdown-1/report-1.html

Large diffs are not rendered by default.

147 changes: 147 additions & 0 deletions inst/report-templates/rmarkdown-1/report-1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
---
title: Trawler Report
date: "Date: 2021-12-30 13:10:56"
output:
html_document:
keep_md: yes
toc: yes
toc_float: true
number_sections: true
# css: ../analysis/common/styles-1.css
params:
path_checks: "not-set"
---

<!-- Set the report-wide options, and point to the external code file. -->


<!-- Suppress the output when loading packages. -->


<!-- Load any global functions and variables declared in the R file. Suppress the output. -->


<!-- Load the datasets. -->


<!-- Tweak the datasets. -->



Smells {.tabset .tabset-fade}
=============================

A *smell* test won't validate a specific record (like the rules below), but it will make sure the dataset overall smells correct.

Smell Summary
-----------------------------
<table class="table table-hover table-condensed table-responsive" style="width: auto !important; ">
<thead>
<tr>
<th style="text-align:left;font-weight: bold;color: white !important;background-color: #555 !important;"> Smell Name </th>
<th style="text-align:right;font-weight: bold;color: white !important;background-color: #555 !important;"> Priority </th>
<th style="text-align:left;font-weight: bold;color: white !important;background-color: #555 !important;"> Proportion of... </th>
<th style="text-align:left;font-weight: bold;color: white !important;background-color: #555 !important;"> Legal Boundaries </th>
<th style="text-align:right;font-weight: bold;color: white !important;background-color: #555 !important;"> Value </th>
<th style="text-align:left;font-weight: bold;color: white !important;background-color: #555 !important;"> Pass </th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> average bmi at baseline </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Average BMI is between 18 and 24 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [18.00, 24.00] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 24.8500 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> average serum ferritin levels at baseline </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> Mean serum ferritin levels are in the recommended range of &gt; 500ng/dl-1200ng/dl </td>
<td style="text-align:left;color: #555 !important;"> [501, 1200] </td>
<td style="text-align:right;color: #555 !important;"> 589.12 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> definitive diagnosis </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> A 100 percent of study participants were diagnosed with malnutrition associated with Chronic Renal Disease </td>
<td style="text-align:left;color: #555 !important;"> [1.00, 1.00] </td>
<td style="text-align:right;color: #555 !important;"> 1.0000 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> dialysis adequacy </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> Normal range for Kt/V values are between 1.2 and 5 </td>
<td style="text-align:left;color: #555 !important;"> [1.20, 5.00] </td>
<td style="text-align:right;color: #555 !important;"> 1.9167 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> mean age </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> Mean age of participants is between 18 years to 20 years </td>
<td style="text-align:left;color: #555 !important;"> [20.00, 80.00] </td>
<td style="text-align:right;color: #555 !important;"> 44.3889 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> mean serum cholesterol levels at baseline </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> Average Cholesterol levels range is between 100mg/dl-140mg/dl at baseline level </td>
<td style="text-align:left;color: #555 !important;"> [100.00, 140.00] </td>
<td style="text-align:right;color: #555 !important;"> 134.1176 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> mean serum creatinine level at baseline </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Mean serum creatinine levels at baseline are between 3mg/dl and 15mg/dl </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [3.00, 15.00] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 23.1687 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> mean serum prealbumin level at baseline </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Mean serum pre-albumin levels at baseline are between 31mg/dl and 39mg/dl </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [32.00, 39.00] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 23.6667 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> normalized protein catabolic rate </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Average Normalized Protein Catabolic Rate is &lt; 1.2g/kg/day </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [0.00, 0.12] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 0.9313 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;"> nutritional counseling </td>
<td style="text-align:right;color: #555 !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;"> Most patients agreed to receiving nutritional counseling </td>
<td style="text-align:left;color: #555 !important;"> [0.85, 0.99] </td>
<td style="text-align:right;color: #555 !important;"> 0.8889 </td>
<td style="text-align:left;color: #555 !important;"> TRUE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> proportion female participants </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Proportion female participants is half the participants till study conclusion </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [0.50, 0.50] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 0.4444 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
<tr>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> proportion male participants </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 1 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> Proportion male participants is half the participants till study conclusion </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> [0.50, 0.50] </td>
<td style="text-align:right;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> 0.5556 </td>
<td style="text-align:left;color: #555 !important;font-weight: bold;background-color: #f1b6da !important;"> FALSE </td>
</tr>
</tbody>
</table>

0 comments on commit 18283b4

Please sign in to comment.