Render a template report
render_report.Rd
render_report()
generates a report for a given template and year. The final
output can be viewed interactively in RStudio. Reports can also be rendered
across multiple years.
Usage
render_report(
template_name,
disease,
estimated = NULL,
notified = NULL,
year = NULL,
vars = NULL,
interactive = TRUE,
override_vars_check = FALSE
)
Arguments
- template_name
String containing the name of the template to render. Run
view_templates()
to see a list of valid options.- disease
A character of length one identifying the disease for which the user wants to build a wide table. The tibble
dxgap_diseases
shows the diseases that are currently supported.- estimated
Override the default
NULL
with a dot-separated character indicating which field from which table should be used as estimated cases for DX Gap computation. If kept toNULL
, the function will use the valueestimates_table.estimates_field
from thenotified
column in thedxgap_diseases
meta table.- notified
Override the default
NULL
with a dot-separated character indicating which field from which table should be used as notified cases for DX Gap computation. If kept toNULL
, the function will use the valuenotifications_table.notifications_field
from thenotified
column in thedxgap_diseases
meta table.- year
Integer matching the year(s) of the report to be rendered. Can be a single integer like
2019
, or a vector of integers such as2019:2021
. The argument is to passed tobuild_dm()
under the hood.- vars
A vector of strings naming columns to subset the data on. Defaults to NULL, indicating all variables should be used.
- interactive
Logical indicating whether to open the report with the RStudio Viewer.
- override_vars_check
Logical indicating whether to override checks on supported vars. Defaults to FALSE. If TRUE, consistent results are not guaranteed.
On override_vars_check
This check consists in comparing the character vector of variable names
supplied by the user through the vars
argument, with those that were
selected in light of the exploratory data analysis. If some of the provided
variables are not part of the original subset, the function will throw an
error. However, new variables names can always be added overriding the check
by setting override_vars_check = TRUE
. If a new variable name should be
part of the core subset, it should be added to the dxgap_diseases
tibble.
Examples
if (FALSE) {
tb_vars <- c("year", "is_hbc", "country_code", "dx_gap",
"pop_total", "pop_urban_perc", "pop_density", "gdp", "c_newinc",
"e_inc_num", "e_mort_100k", "culture", "smear", "xpert", "m_wrd")
render_report(
template_name = "eda.Rmd",
disease = "tb",
estimated = "who_estimates.e_inc_num",
notified = "who_notifications.c_newinc",
year = 2019,
vars = tb_vars
)
}