An analysis isn't done until it's communicated. R Markdown and Quarto are R's reproducible reporting tools — a single document combining narrative, code, and output, rendered to HTML, PDF, or Word.
R Markdown — the original
---title: "Kenyan banking spread analysis"author: "You"output: html_document---## IntroductionWe analyse 21 months of commercial bank lending rates...```{r}library(dplyr)library(ggplot2)bankrates |>mutate(spread = lending_rate - deposit_rate) |>summarise(mean_spread = mean(spread))```The mean spread is shown above.
The .Rmd file mixes Markdown narrative with code chunks. When you knit (Ctrl+Shift+K in RStudio), R runs every chunk in order and produces the rendered output document.
Quarto — the modern successor
Quarto is R Markdown's successor, by the same team. It supports R, Python, and Julia equally; it has more output formats; and it ships with a smarter default theme. The syntax is nearly identical (.qmd files); migration is trivial. New projects should default to Quarto.
Code chunks — options
```{r my-chunk, echo = FALSE, message = FALSE, warning = FALSE, fig.width = 8}# echo = FALSE: don't show the code, only the output# message/warning = FALSE: suppress noise# fig.width: chart dimensions```
Parameterised reports
You can parameterise a Quarto/Rmd document — pass values in via YAML or the command line — to produce country-specific or period-specific versions of the same report. Useful for monthly economic updates.
When to use Quarto vs a Shiny app
Quarto: a static rendered document, refreshed on a schedule. Shiny: interactive — sliders and dropdowns drive a live recomputation. Quarto for reports; Shiny for tools.
Reproducibility is the point
The whole reason you're using R Markdown / Quarto is so that next year, when someone asks 'where did this number come from?', you can re-knit the same document and get the same answer. Avoid hard-coded values in narrative — always reference inline R: the spread is `r round(mean_spread, 3)`%.
Exercise
Write a YAML header for a Quarto document titled 'Pension allocation analysis' that outputs HTML.