Skip to contents

Generates a clean, self-contained Quarto markdown document combining a structured study overview, LaTeX mathematical model specification, an auditable table of inferred defaults and rationales, the validated YAML IR, and the deterministic AST-verified simulation script produced by compile_r_script(). All free-text metadata, prompts, and rationales are strictly sanitized against Quarto frontmatter breakouts, inline knitr code execution, markdown code-fence escapes, HTML/XSS tags, and dangerous LaTeX macros.

Usage

compile_quarto_report(spec, file = NULL, format = "html", execute = TRUE)

Arguments

spec

A validated spec_ir object.

file

Optional file path; when provided, writes the .qmd report to file and returns the document text invisibly.

format

Quarto output format (e.g., "html", "pdf", "docx").

execute

Logical; whether Quarto code chunks should execute on render (eval: true vs eval: false). Defaults to TRUE.

Value

A character scalar containing the Quarto .qmd document (invisibly when file is provided).

Examples

spec <- new_spec_ir(
  design_type = "power_analysis",
  hierarchy = list(levels = 2L, n_clusters = 40L, cluster_size = 20L, icc = 0.2),
  simulation = list(n_reps = 50L, seed = 2026L)
)
qmd <- compile_quarto_report(spec)
cat(substr(qmd, 1, 500))
#> ---
#> title: "Untitled Statistical Study"
#> subtitle: "Reproducible Statistical Simulation Report (specshiny IR v1.2.0)"
#> format: html
#> execute:
#>   echo: true
#>   warning: false
#>   message: false
#>   eval: true
#> ---
#> 
#> ## 1. Study Design Overview
#> 
#> 
#> | Component | Specification |
#> | :--- | :--- |
#> | **Design Type** | `power_analysis` |
#> | **Data Hierarchy** | 2-level (40 clusters x 20 observations; total N = 800; ICC = 0.2) |
#> | **Outcome** | `y` (`gaussian`, `identity` link) |
#> | **Focal Term** | `x1` (true effect =