5 Assignment 5: R Script → Quarto Report
From analysis script to a reproducible, published HTML report
6 Overview
This week, you will take your Week 3 homework assignment (NYPD Shooting Incidents) and convert it into a Quarto report (.qmd). Using the same prompt and the work you already completed, your task is to create a fully reproducible, publishable HTML report.
Your final output should read like a short research note: code + narrative explanations + tables/plots + brief interpretation.
7 Learning Objectives
By completing this assignment, you will be able to:
- Convert an analysis workflow from an R script into a reproducible Quarto document
- Organize work into labeled code chunks that render cleanly to HTML
- Combine narrative text with analysis code to communicate findings
- Use inline R expressions to report values dynamically
- Create publication-quality tables and visualizations for the web
- Publish a reproducible report and share it via a link
8 Textbook Connection
This assignment builds directly from Chapter 10: Reproducible Reporting in Reproducible Research Using R.
Students are encouraged to review the chapter before beginning this assignment, as it provides the conceptual foundation and reproducible workflow demonstrated here.
9 Submission Instructions
Submit two things:
- A link to your published HTML report (e.g., RPubs, Posit Connect/Cloud, GitHub Pages, etc.)
- Your
.qmdfile
Your Quarto report must render to HTML without errors.
10 Assignment Tasks
Your Quarto document must include the following sections and components.
10.1 1. YAML header
Include:
- Title
- Your name as the author
10.2 2. Setup chunk
Load all required libraries (for example: tidyverse, lubridate, ggplot2, nycOpenData, etc.).
10.3 3. Minimum required code chunks (4)
Your report must contain at least the following four code chunks:
Data ingest
UsenycOpenData::nyc_shooting_incidents()to load the NYPD shootings dataset.Data cleaning
At least two cleaning/feature steps (examples: dropping NAs, creatingtime_of_day, lowercasing a column, creatingdays_since).Insights
Include the code used to generate your Week 3 insights (grouped summaries, counts, etc.).Tables & Graphs
- At least one table created with
knitr::kable() - At least two ggplot2 graphs:
- one related to
time_of_day - one supporting your personal insight
- one related to
- At least one table created with
All tables and graphs must have captions!
10.4 4. Narrative text
After each code chunk, write a short explanation describing:
- what you did
- why you did it
- what you learned or produced
10.5 5. Inline R expression
Include at least one inline R expression in your narrative text.
Example:
The dataset contains
r nrow(shooting_data)rows after cleaning.
10.6 6. Hyperlink to the dataset
Provide a clickable link to the dataset (not a raw URL pasted as plain text).
Example:
NYC Open Data Portal — NYPD Shooting Incident Data
(You may link directly to the dataset page if you prefer.)
10.7 Reflection
In 3–5 sentences, explain how this workflow could potentially help you in your thesis research.
11 Publishing Instructions
- Render your Quarto document to HTML.
- Publish it online (e.g., RPubs).
- Submit:
- the link to the published HTML
- your
.qmdfile
12 Reproducibility Practice (Quarto Reporting)
This assignment focuses on reproducibility as communication.
In your report:
- Chunk labels should be meaningful (e.g.,
data-ingest,cleaning,insights,plots) - Your narrative should match your code (a reader should understand what each chunk accomplishes)
- Inline R values should be used to avoid hard-coding numbers that may change if the dataset updates
- Your HTML output should render cleanly and be readable without needing the original script
13 Publishing Instructions
- Render your
.qmdfile to HTML. - Confirm that warnings and messages do not appear in the final document.
- Submit both your
.qmdfile and your published.htmlreport.