Quiz: Interactive Data Storytelling

Week 12 · Advanced Statistical Programming using R

Recap: Communication & Visualisation

Q1

Where should the units of a numeric column (e.g. mm, g) go in a well-designed table?

  1. In every cell next to the value
  2. In a separate “units” column
  3. In the column header
  4. In a footnote at the bottom

Answer: 3) Units belong in the column header, e.g. “Bill length (mm)”. This keeps cells scannable and reduces visual clutter.

Q2

What are the main roles of the subtitle and caption below a chart?

  1. Both repeat the axis labels
  2. Subtitle states the finding, caption credits the data source
  3. Both are optional and rarely used
  4. Subtitle lists the data points, caption lists the axes

Answer: 2) The subtitle carries the message. The caption grounds the chart in its source, so readers can verify or cite it.

Interactive Visualisation

Q3

What is the fastest way to turn an existing ggplot2 plot into an interactive one?

  1. Rewrite it manually in JavaScript
  2. Wrap it in ggplotly()
  3. Save it as PDF
  4. Run install.packages("plotly") only

Answer: 2) ggplotly(p) converts a static ggplot2 object into an interactive plotly chart. Hover, zoom, and legend toggles work automatically.

Q4

Which package category works without needing a running R server?

  1. htmlwidgets like plotly, leaflet, DT
  2. Shiny apps
  3. Any package that renders in the browser needs a live R backend
  4. Any package with server in the name

Answer: 1) htmlwidgets embed pre-rendered JavaScript into HTML. They work in any Quarto or R Markdown HTML output and static sites like GitHub Pages.

Q5

Which interactive features does plotly add to a plot? (multiple correct answers)

  1. Hover tooltips showing exact values
  2. Click legend entries to hide or show groups
  3. Automatic statistical modelling
  4. Box-select or zoom to explore subsets

Answer: 1, 2 & 4)
Correct: 1. Hover tooltips reveal values on mouse-over.
Correct: 2. Legend clicks toggle groups on and off.
Correct: 4. Box-select and zoom highlight regions of interest.
False: 3. plotly renders plots, it does not fit models.

Q6

You want to add a marker at a specific latitude and longitude on an interactive map. Which pipeline works?

  1. ggplot() + geom_point()
  2. plot() + points()
  3. map_data("world") + geom_polygon()
  4. leaflet() |> addTiles() |> addMarkers(lng, lat, popup)

Answer: 4) leaflet() starts the map, addTiles() supplies the OpenStreetMap background, addMarkers() places pins with popups.

Geospatial Visualisation

Q7

What is an sf object in R?

  1. A special image file with map data
  2. A raster grid of pixel values
  3. A data frame with a geometry column
  4. A wrapper around Google Maps

Answer: 3) sf (Simple Features) objects behave like normal data frames. The geometry column stores the shape, and you can pipe through dplyr as usual.

Q8

What does geom_sf() do in a ggplot2 call?

  1. Fits a spatial regression model
  2. Draws the geometry column of an sf object with automatic projection handling
  3. Reads shapefiles from disk
  4. Converts a data frame into sf format

Answer: 2) geom_sf() plots the geometry column and manages the map projection. Combine it with aes(fill = ...) for choropleths.

Q9

When would you prefer {geofacet} over a standard choropleth (geom_sf())?

  1. When exact geographic boundaries are essential
  2. When you have no geographic data at all
  3. When you want to avoid using ggplot2
  4. When comparing a trend or distribution across regions in small multiples

Answer: 4) {geofacet} arranges facet_wrap() panels in a geographic layout. Great for showing time series or distributions per region side by side.

Looking Ahead: Multi-lingual Analysis

Q10

Which R package lets you call Python code and share data between both languages in the same session?

  1. dplyr::python
  2. pydiverse
  3. reticulate
  4. Rython

Answer: 3) reticulate is R’s bridge to Python. It lets you import Python modules, run scripts, and pass data frames back and forth in one Quarto document.