Render a water-quality report from the internal R Markdown template
Source:R/report.R
render_report.RdRenders an HTML report using the package's internal R Markdown template. By default, the output is written to a temporary directory to comply with CRAN policies. The function returns (invisibly) the full path to the generated file.
Usage
render_report(
df,
meta = list(river = NA, period = NA),
output_file = "wq_report.html",
output_dir = tempdir(),
template = system.file("templates", "report_rmd.Rmd", package = "tikatuwq")
)Arguments
- df
Data frame with the input data used by the template.
- meta
Named list with contextual metadata (e.g.,
river,period).- output_file
File name for the report (default
"wq_report.html").- output_dir
Directory where the file will be written (default
tempdir()). It will be created if it does not exist.- template
Path to the internal template file. Defaults to the package Rmd template shipped under
inst/templates/report_rmd.Rmd.
Details
The template expects a data frame with columns compatible with the package
(e.g., ponto, data, parameters used by IQA/CONAMA checks). You can pass
optional metadata via meta, such as river and period.
This function relies on rmarkdown (listed in Suggests). If the package is not available, an informative error is thrown.
Notes
The default output directory is
tempdir()to avoid writing into the user's project folder during examples or automated checks.The template is an Rmd (R Markdown). If you prefer Quarto, provide a custom
templatepath to a.qmdand ensure your environment supports it.
Examples
# \donttest{
# Minimal example (writes to a temporary directory)
d <- wq_demo
path <- render_report(d, meta = list(river = "Example River", period = "Jan–Feb"))
file.exists(path)
#> [1] TRUE
# }