Builds a detailed report for every dataset with a unique dataset_id, based on a Quarto (.qmd) template.
The reports are rendered as html files and saved in the specified output folder.
dataset_report(
dataset_id,
database,
overwrite = FALSE,
output_path = "export/reports",
input_file = NULL,
quiet = TRUE,
keep = FALSE,
show_questions = TRUE
)Name of specific study/dataset
A compiled database
Logical value to determine whether to overwrite existing report
Location where rendered report will be saved
Report template (.qmd) to build the study report from. The
default, NULL, uses config/report_dataset.qmd if the working directory
has one, and otherwise the generic template shipped with traits.build (see
the Report template section). A path given here is always used.
An option to suppress printing during rendering from knitr, Quarto and pandoc
Keep the temporary, per-dataset copy of the template (see the Report template section)?
Include the questions to the data contributor? The
default, TRUE, gives the review copy; FALSE gives a final copy with all
questions (and the explanatory text about them) omitted.
Invisibly, a logical named by dataset_id, TRUE where the report
was written. Reports are rendered as html files in output_path. A dataset
whose report fails to render warns and returns FALSE rather than aborting
the batch.
Run this from the root of the database's repository: the report reads each
dataset's data/<dataset_id>/metadata.yml from there.
traits.build ships a generic template, which introduces the database from
its own metadata (the metadata block of config/metadata.yml: title,
version, description, DOI, reference, repository and licence) and works for
any database the package builds.
A database can use its own template instead by saving it as
config/report_dataset.qmd, beside its other build inputs. When
input_file is NULL, dataset_report() uses that file if it exists in the
working directory, and otherwise the generic template. To start one, copy
the generic template:
file.copy(system.file("support", "report_dataset.qmd", package = "traits.build"),
"config/report_dataset.qmd")A template receives the parameters dataset_id, austraits_path (the
compiled database, saved as .rds) and show_questions, and must declare
all three under params: in its YAML header, or rendering fails. It also
needs a title: line there, which dataset_report() replaces with the
dataset's id. The template is copied into the working directory and
rendered from there, so any path it uses, such as an image or an included
file, is relative to the working directory, not to config/. keep = TRUE
leaves that copy, tmp_<dataset_id>_report.qmd, in the working directory.