Render (executed) checks to an html document with R Markdown

render_rmarkdown(
  path_checks,
  directory_output,
  report_file_name = "trawler.html",
  path_template = system.file("report-templates/rmarkdown-1/report-1.Rmd", package =
    "trawler")
)

Arguments

path_checks

The file path of the output of execute_checks(). Required.

directory_output

A writable directory to save the report outputs. The html file is the primary output. The markdown file is sometimes useful too. Required.

report_file_name

The name of the resulting html file. Defaults to "trawler.html".

path_template

The rmd file, which serves as the report template. Defaults to the standard template built into the trawler package.

Examples

# Step 0: define paths.
#   So this package example executes on every machine, temp files are used.

# Replace the two paths for your specific project
path_data    <- system.file("datasets/pt-event-biochemical.rds", package = "trawler")
path_defs    <- system.file("checks/checks-biochemical.yml", package = "trawler")

# In your real code, this will probably in a static directory.
# If PHI or sensitive info is contained, use a secure location.
directory_output <- file.path(tempdir(check = TRUE), "trawler")
if (!dir.exists(directory_output)) dir.create(directory_output)
path_checks <- tempfile("trawler-checks-", fileext = ".rds", tmpdir = directory_output)

# Step 1: load the check definitions and the dataset to test
ds_pt_event  <- readr::read_rds(path_data)
checks       <- load_checks(path_defs, origin = "REDCap")

# Step 2: execute the checks and save to an rds file
ds_pt_event |>
  execute_checks(checks, origin = "REDCap") |>
  readr::write_rds(path_checks)

# Step 3: render checks as an html report with R Markdown
render_rmarkdown(path_checks, directory_output)
#> 
#> 
#> processing file: report-1.Rmd
#> 1/25                      
#> 2/25 [set-options]        
#> 3/25                      
#> 4/25 [load-packages]      
#> 5/25                      
#> 6/25 [declare-globals]    
#> 7/25                      
#> 8/25 [load-data]          
#> 9/25                      
#> 10/25 [tweak-data]         
#> 11/25                      
#> 12/25 [table-rule-summary] 
#> 13/25                      
#> 14/25 [table-rule-detail]  
#> 15/25                      
#> 16/25 [rules-inactive]     
#> 17/25                      
#> 18/25 [table-smell-summary]
#> 19/25                      
#> 20/25 [smells-inactive]    
#> 21/25                      
#> 22/25 [session-info]       
#> 23/25                      
#> 24/25 [session-duration]   
#> 25/25                      
#> output file: report-1.knit.md
#> /usr/local/bin/pandoc +RTS -K512m -RTS report-1.knit.md --to html4 --from markdown+autolink_bare_uris+tex_math_single_backslash --output /private/var/folders/0g/hj_q_pzx65bbjnslxz9n0src0000gn/T/RtmpQ0K5Rg/trawler/trawler.html --lua-filter /Users/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/pagebreak.lua --lua-filter /Users/runner/work/_temp/Library/rmarkdown/rmarkdown/lua/latex-div.lua --embed-resources --standalone --variable bs3=TRUE --section-divs --table-of-contents --toc-depth 3 --variable toc_float=1 --variable toc_selectors=h1,h2,h3 --variable toc_collapsed=1 --variable toc_smooth_scroll=1 --variable toc_print=1 --template /Users/runner/work/_temp/Library/rmarkdown/rmd/h/default.html --no-highlight --variable highlightjs=1 --number-sections --variable theme=bootstrap --mathjax --variable 'mathjax-url=https://mathjax.rstudio.com/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML' --include-in-header /var/folders/0g/hj_q_pzx65bbjnslxz9n0src0000gn/T//RtmpQ0K5Rg/rmarkdown-str160a2f578b5f.html 
#> 
#> Output created: /private/var/folders/0g/hj_q_pzx65bbjnslxz9n0src0000gn/T/RtmpQ0K5Rg/trawler/trawler.html

# For the sake of this example, clean up temp files.
#    You probably do NOT want this line in your real code.
unlink(directory_output, recursive = TRUE)