- Reporting analyses has become very customizable with the help of R Markdown. Users can write code, text, and display results all within the same document.
Incorporating parameters into an R Markdown document can take customizability a step further.
Parameters allow users to run the same report across different scenarios:
Showing the results for different diagnoses
Selecting certain years for the report
Showing results under different assumptions
Changing the behavior of knitr
R types that can be parsed by yaml::yaml.load() can be included as parameters (character, numeric, integer, logical)
R objects can be included with '!r' before the R expression
Parameters can be accessed within a read-only list called params.
Simply include 'params$' and the parameter to be accessed:
params$surgery
params$year
etc.
The graphical user interface is based on Shiny. It's used to interactively select inputs for the report.
It can be accessed by:
'Knit' dropdown > 'Knit with Parameters' or
rmarkdown::render("My_Parameter_Document.Rmd", params="ask")
What if we wished to constrain 'year' to a certain range, or we wished to display discrete options for 'surgery'?
Inputs for parameters can be controlled by additional arguments in the YAML.
The graphical UI has the ability to provide different features for input selection such as sliders, check boxes, text boxes.
The Input field controls the type of feature. Below is a list of the different inputs currently supported.
To create these features, sub-items can be specified under the parameters in the YAML:
These interactive features are very helpful when others are accessing your report, such as with RStudio Connect (https://www.rstudio.com/products/connect/)
https://bookdown.org/yihui/rmarkdown/parameterized-reports.html