Turn your leaf analysis into a professional Word document
2026-07-05
This activity parallels the lecture. Go slowly — you do not need to type fast. Each step is small, and there is a finished template you can lean on.
📥 Download the template
Download the template report → leaf_report_template.qmd
Save it into your project’s documents/ folder. It already has the YAML, the library chunk, a summary table, and a figure. You will study it in Step 6 and use it as a safety net if you fall behind.
👀 See a finished report first — why we bother
Before you build your own, open this worked example and render it:
t_test_report.qmd — the exact t-test from Worksheet 04, written up as a Quarto report. The t-statistic, p-value, and group means are dropped straight into the sentences with inline code, and it renders to a clean Word document. That is the payoff of everything in this activity: the analysis you already ran becomes a report that writes its own numbers. Notice you would never copy a single value by hand.
What you need open: Positron, your class project folder (data/, documents/, figures/, scripts/), and your leaf data in data/.
In Positron: File → New File → Quarto Document. Save it right away into your documents/ folder as my_leaf_report.qmd.
Note
A .qmd file is just plain text. You can open it anywhere, and it lives happily inside your project like your scripts do.
At the very top of the file, type this between two lines of three dashes. Use spaces, never tabs, for the indenting.
Press Render (Ctrl/Cmd + Shift + K). A blank-ish Word document should open with your title on it. 🎉 You just made a Word file from plain text.
Warning
If Render fails, check that both --- lines are alone on their own line and that your indenting is spaces.
Below the YAML, write a few lines using Markdown symbols:
Render again. Notice the # became a real heading and the - became bullets.
Insert a chunk with Ctrl/Cmd + Alt + I, then make it load your packages and data. Give it a short name after r:
Add a second, uniquely named chunk to read your data:
Render. If it breaks, the message names the chunk — go straight to it.
Tip
Same habit as your scripts: small, uniquely named chunks make errors easy to find. No two chunks can share a name.
Add a chunk that calculates the group means:
Then, in your text, use inline code to insert the number automatically:
Render. The real number appears in the sentence — and you never typed it.
Now upgrade your YAML to match the downloaded template so the report gets a table of contents and numbered sections:
Open leaf_report_template.qmd side by side. Copy in its summary-table and leaf-plot chunks so your report has a real table and figure. Render.
Note
Set echo: false in the execute: block (top of the file) to hide the code so your report shows only results — the way a reader wants it.
Change your format: block to build a Word file, a web page, and slides — all from the same analysis:
Render. Three documents, zero extra work.
You are done when you can:
.qmd to a Word document with a title, TOC, and numbered sections🖐 Stuck or behind?
Open leaf_report_template.qmd, render it as-is to confirm your setup works, then compare it to your file chunk by chunk. For a fuller example with a real statistical test, study t_test_report.qmd.
Render to Word and submit both:
my_leaf_report.qmd (your source file)my_leaf_report.docx (the rendered report)References: 📖 R4DS Ch 28 — Quarto · 📖 R4DS Ch 29 — Formats · 🌐 quarto.org guide