Skip to contents

This function creates an index Quarto file (QMD) that merges all chapters in the specified order. It can also include optional title and author(s) information.

Usage

gen_qmd_file(
  path = NULL,
  filename = "report",
  yaml_file = NULL,
  format = "html",
  qmd_start_section_filepath = NULL,
  qmd_end_section_filepath = NULL,
  chapter_structure = NULL,
  include_files = NULL,
  title = NULL,
  authors = NULL,
  output_formats = NULL,
  output_filename = NULL,
  includes_prefix = "{{< include \"",
  includes_suffix = "\" >}}",
  call = rlang::caller_env()
)

Arguments

path

String, where to write qmd-file.

filename

String, bare name of qmd-file. Default: "report". If NULL, generates a sanitized version of the title. If both filename and title are NULL, errors.

yaml_file

A string containing the filepath to a yaml-file to be inserted at top of qmd-file.

format

Quarto output format written into the YAML

scalar<character> // default: "html" (optional)

Written as the format: field of this file's YAML front matter, and passed through verbatim, so any value Quarto accepts works. Documented here rather than inherited from draft_report(), whose description covers chapters, index.qmd and the combined report and names three separate *_yaml_file arguments — this function writes one file and takes one yaml_file.

Ignored when yaml_file is supplied, since that file then provides the whole front matter, format: included.

qmd_start_section_filepath, qmd_end_section_filepath

String, filepath to a qmd-file inserted at start and end of file.

chapter_structure

What goes into each chapter and sub-chapter

obj:<data.frame>|obj:<tbl_df> // Required

Data frame (or tibble, possibly grouped). One row per chapter. Should contain the columns 'chapter' and 'dep', Optionally 'indep' (independent variables) and other informative columns as needed.

title

Title of report

scalar<character> // default: NULL (optional)

Added automatically to the YAML-header of the index.qmd and report.qmd-files. If NULL, no title field is written to those files.

Each chapter qmd-file instead receives its own value of the chapter-column as its YAML title, so chapters are titled correctly regardless of this argument.

authors

Authors of entire report

vector<character> // default: NULL (optional)

If NULL, infers from chapter_structure[[authors_col]], and collates for entire report. If multiple authors per chapter, separate with semicolon. Ensure consistency.

output_filename, output_formats

Character. If applied, will construct list of links to files with said output_filename.

call

Internal call argument. Not to be fiddled with by the user.

Value

A string containing the filepath to the generated Quarto report file.