Skip to main content

Assignment 5 Walkthrough and Reference

Where this fits

You have the worked example, the failure modes, the prompt templates, and the studio drafts. This page is the bridge from in-class work to the Assignment 5 submission. The deliverables listed here are the same set in the A5 README — this page explains what goes into each one and how to verify it.

The seven A5 deliverables, explained

Each file goes in assignments/assignment05-visualization/submission/.

1. visualization-audit.qmd

A rerunnable Quarto file that loads the cached CSV with a relative path, prepares a descriptive summary, renders the final corrected plot, and includes one or two short paragraphs explaining what you revised and why.

  • Verify: open it in a fresh Codespace, render top to bottom, no errors.

2. visualization-audit.html

The rendered output of the .qmd above. Quarto writes this when you click Render.

  • Verify: open the HTML in the Codespaces preview and confirm the figure, caption, and audit paragraph all appear.

3. corrected-plot.png

The exported corrected plot as a static image, written from code rather than by screenshot.

To save your corrected ggplot, use:

ggsave(
  "assignments/assignment05-visualization/submission/corrected-plot.png",
  plot = last_plot(),
  width = 7,
  height = 5
)

Confirm the file appears in the submission folder before committing.

Step by step:

  1. Run the code that draws your corrected plot, so it is the most recent figure in your session.
  2. Run the ggsave() call above. plot = last_plot() means “the most recent ggplot I drew.” If you stored the plot in a variable, pass that instead: plot = my_corrected_plot.
  3. The path starts from the repository root, so run it from there. If your R session is already inside the submission folder, shorten the path to "corrected-plot.png".
  4. Check the result in VS Code: find the PNG in the Explorer panel, right-click it, and choose Open Preview to confirm it opens and looks right.
  • Verify: the PNG exists, opens, and matches what the rendered HTML shows.

4. visual-audit-note.md

A short note listing at least three issues you identified in the flawed plot from viz06. For each issue, write one sentence on what it was, one sentence on why it matters, and one sentence on how you corrected it.

  • Verify: three issues, each tagged with a category from viz04 (correctness, design, interpretation, bias/aggregation, or reproducibility).

5. caption.md

The caption for your final figure. Use the template from viz03:

This figure shows [measure] by [group] across [time/category] using the prepared NHANES Health Equity classroom dataset. The summary is descriptive and unweighted. Records with missing [variables] were excluded. The plot supports comparison of patterns, not causal claims or population-level estimates.

  • Verify: the caption names the statistic, the data source, the exclusions, and one limitation.

7. ai-use-note.md

If you used AI to draft code or wording, name what it helped with and how you verified the result. If you did not use AI, write one sentence saying so.

Copy your inline # AI prompt: / # Verified: comment pairs into the note’s audit trail. The template and a filled example are on the assignments index.

  • Verify: specific (which chunk? which prompt template?), not vague (“I used Copilot”).

Reproducibility checklist for A5

Before you click submit:

  • The .qmd renders in a fresh Codespace with no manual edits.
  • The data path is relative (examples/nhanes-equity/data/nhanes_equity_v6.csv).
  • The PNG is generated by code (or a documented render step), not by screenshot.
  • The caption uses the descriptive template and does not imply causality or national prevalence.
  • Use the course devcontainer packages. If an additional package was approved, record it in your dependency note and the workspace setup so a fresh Codespace can install it.
  • All seven files are committed and pushed to your GitHub repo.

Accessibility (good practice, not a graded deliverable)

A plain-language alt text sentence next to your figure helps screen-reader users, colour-blind reviewers, and busy policymakers. The A5 rubric does not score alt text — it is encouraged practice. If you want to try it, add fig-alt: as a chunk option:

ggplot2 quick reference

Need Code Note
Load packages library(tidyverse) Every session
Set data + mapping ggplot(df, aes(x, y)) The starting point
Points geom_point() Use alpha for overlap
Lines connecting summaries geom_line() + geom_point() Better than geom_smooth() for descriptive cycle data
Bars / columns geom_col() For pre-aggregated counts
Labels labs(title, subtitle, x, y, caption) Caption goes under the figure
Honest y-axis expand_limits(y = 0) Start at zero unless you justify otherwise
Theme theme_minimal() Clean default
Save figure ggsave("plot.png", plot, width = 6, height = 4) Code-generated, not screenshot; for A5 use the full submission-folder path (see deliverable 3)

Visual audit checklist

A short version of the five questions from viz04:

  • Title and caption do not imply causation.
  • Y-axis starts at 0 or has a stated reason.
  • Geometry suits descriptive data (no smoother across categorical x).
  • Weighted vs unweighted is stated.
  • Missingness and exclusions are disclosed.
  • Small-cell counts are visible or filtered out.

Five quick knowledge checks

  1. What are the five moving parts of a ggplot?
  2. Name two failure modes from viz04 and one fix for each.
  3. Why is geom_smooth(method = "lm") rarely appropriate for NHANES cycle data?
  4. What two lines of comment should appear above any AI-drafted chunk?
  5. What is the difference in scope between Assignment 5 and the M1 initial-visual-plan.md?

Where this goes next

Next week (Week 7) builds the EDA evidence behind the descriptive claims you have been plotting: cohort definition, missingness reporting, Table 1, and the AI audit categories.