Reproducible Reports
39.1 Quarto (.qmd) — the modern standard
Quarto produces HTML, PDF (LaTeX/Typst), Word, PowerPoint, Reveal.js slides, websites, books, blogs, and dashboards; supports R, Python, Julia and Observable JS; cross-references, citations (BibTeX), callouts, tabsets, and interactive widgets.
---
title: "Penguin Report"
author: "Your Name"
date: today
format:
html:
toc: true
code-fold: true
pdf: default
docx: default
execute:
echo: true
warning: false
params:
species: "Adelie"
---
## Introduction
This report analyses **`r params$species`** penguins.The mean mass is `r round(mean(penguins$body_mass_g, na.rm = TRUE))` g (see @fig-mass).quarto render report.qmd
quarto render report.qmd -P species:Gentoo # parameterized report
quarto preview report.qmd39.2 R Markdown (.Rmd)
The predecessor (still widely used): rmarkdown::render("report.Rmd"). Chunk options: echo, eval, include, message, warning, fig.width, cache. Ecosystem: bookdown, blogdown, xaringan, flexdashboard, pagedown, distill.
39.3 Tables for reports
knitr::kable(head(mtcars))
gt::gt(head(mtcars)) |> gt::fmt_number(columns = mpg, decimals = 1) |> gt::tab_header(title = "Cars")
flextable::flextable(head(mtcars)) # great for Word/PowerPoint
gtsummary::tbl_regression(lm(mpg ~ wt, mtcars))
reactable::reactable(mtcars) # interactive HTML table
DT::datatable(mtcars, filter = "top")39.4 Literate programming tips
Keep raw data read-only, compute everything in the document, set seeds, print sessionInfo() at the end, and render from a clean session.