Quarto for managers

The magic of automatic reporting ✨

Rhian Davies

Meet Maria

  • Public Health analyst
  • Delivers monthly reports on NHS Workforce statistics
  • Uses Excel & R to analyse data
  • Uses Word to write branded reports

Cartoon of a woman smiling

Monthly Reports

Cartoon of a spreadsheet

Monthly Reports

Cartoon of a spreadsheet, then a woman coding.

Monthly Reports

Cartoon of a spreadsheet, then a woman coding, and then a women designing a pie chart.

Monthly Reports

Cartoon of a spreadsheet, then a woman coding, and then a women designing a pie chart and finally a woman writing some notes.

Back to square one

  • The data was wrong — can you re-run the analysis?

  • Your manager loves it — can you do it for another region?

  • Next month — do it all again.

There must be a better way

Hello quarto 👋

What is quarto?

The quarto logo: A circle cut into four quadrants next to the word quarto

An open-source scientific and technical publishing system

A schematic representing the multi-language input (e.g. Python, R, Observable, Julia) and multi-format output (e.g. PDF, html, Word documents, and more) versatility of Quarto.

Artwork from “Hello, Quarto” keynote by Julia Lowndes and Mine Çetinkaya-Rundel, presented at RStudio Conference 2022. Illustrated by Allison Horst.

👀 Demo: Creating a new report

👩‍💻 Your turn: New report

  • Open binder Launch RStudio Binder
  • File ➡️ New File ➡️ Quarto Document
  • Enter Title & Author
  • Leave HTML selected
  • Click Create
  • Click Render Document (you’ll be prompted to save first)
  • Try changing some text and then re-rendering with Render Document

Interweave text and code 🧶

👀 Demo: Simple plot and text

👩‍💻 Your turn: New report

  • Open binder Launch RStudio Binder
  • Open exercise-2/simple.qmd
  • Click Render
  • Change blue to red and re-render
  • Change the filter to > 2024-12-31 and re-render

Parameterisation ⚙️

Example report

Template based-reports

---
title:"NHS Workforce Statistics for `r params$ics_name`"
subtitle:"Data for `r params$month_year`"
author:"Maria Garcia"
date:"2023-09-28"
params:
  ics_name:"North East and North Cumbria"
  month_year:"April 2023"
---

Read in the data

  filename
= glue(
  "NHS Workforce Statistics, {params$month_year} England and Organisation.xlsx"
)

Clean the data

staff_group =
  staff_group |>
  filter(`ICS name` == params$ics_name) |>
  select(
    `Organisation name`,
    `Total`,
    `HCHS Doctors`,
    `Nurses & health visitors`,
    `Midwives`,
    `Ambulance staff`
  )

Add insight

The table below shows the total number of doctors and nurses for each organisation within `r params$ics_name`. We can see that the organisation with the most midwives is the `r pull(max_midwives, "Organisation name")` with `r round(max_midwives$Midwives)` staff.

Re-run next month

---
title: "NHS Workforce Statistics for `r params$ics_name`"
subtitle: "Data for `r params$month_year`"
author: "Maria Garcia"
date: "2023-09-28"
params:
  ics_name: "North East and North Cumbria"
  month_year: "May 2023"

Report a different region

---
title: "NHS Workforce Statistics for `r params$ics_name`"
subtitle: "Data for `r params$month_year`"
author: "Maria Garcia"
date: "2023-09-28"
params:
  ics_name: "Lancashire and South Cumbria"
  month_year: "May 2023"

👩‍💻 Your turn: Parameters

  • Open binder Launch RStudio Binder
  • Open exercise-3/example-report.qmd
  • Change month_year: July 2025 to June 2025 and re-render
  • Change ics_name: "North East and North Cumbria" to another ICS

Maria is happy

  • More reproducible workflow
  • Fewer mistakes
  • Spends less time formatting the reports manually
  • Spends more time adding insight

Cartoon of a woman smiling