Assignment 5

Assignment 5: Interactive graphics (with Gapminder) using Shiny

Gapminder compiles detailed indicators of global development. For this assignment, you should build a Shiny visualization to tell a story about the data. This assignment requires you to develop both the visualization as well as a written narrative.

  • You do not need to analyze all 500+ variables. You can focus on a small set of variables (whichever ones you wish, though check the indicator’s coverage for all the countries and the time period available)
  • You can build either a highly linear or non-linear structure to your visualization. Note that if you design a non-linear interactive visualization, you still need to situate it using an introduction or text description (a la America’s Public Bible1. See FA ch 9 for more details.)
  • Note: gapminder only contains data on three variables. You will need to obtain additional indicators from Gapminder’s data page. Unfortunately they don’t have a friendly API to access their database - each variable has to be downloaded manually as an Excel spreadsheet and imported into R. The following basic function should allow you to import a downloaded spreadsheet into R,2 and tidy:
library(tidyverse)
library(readxl)

import_gapminder <- function(filename, inc_name = NA){
  # import file
  indicator <- read_excel(filename)
  
  # rename first column to country, store indicator name for later
  inc_fullname <- names(indicator)[[1]]
  names(indicator)[[1]] <- "country"
  
  # tidy data frame and add indicator name as variable
  indicator <- indicator %>%
    gather(year, value, -1, convert = TRUE) %>%
    mutate(value = as.numeric(value),
           variable = ifelse(!is.na(inc_name), inc_name, inc_fullname)) %>%
    select(country, year, variable, value)
}

# use default name
# (import_gapminder("data/indicator hiv estimated prevalence% 15-49 (1).xlsx"))
# 
# # use custom label
# (import_gapminder("data/indicator hiv estimated prevalence% 15-49 (1).xlsx",
#                   inc_name = "hiv_15_49"))

Can I use some different data?

YES! If you have another dataset around which you want to build an interactive visualization, go ahead! Just check in with me before you proceed.

Requirements for a sucessful app:

  • Need either multiple tabs (content in Shiny part I) or a dashboard (content in Shiny part II) with multiple plots.
  • Ideally at least three plots with some narrative component connecting them to one another.
  • All plots should adhere to the same principles of design we have discussed over the quarter
  • Ideally you have some variety in plot types (e.g. not all bar plots)
  • Prefer you use a Shiny theme to make it a little more polished than the baseline shiny app using Shiny Themes (discussed in class) or other theme approaches like thematic or (advanced) theming (bslib).

What do I submit?

Submit the link to your shiny app!

Grading

Your visualization will be evaluated using the following criteria:

  • Is it truthful?
  • Is it functional?
  • Is it beautiful?
  • Is it insightful?
  • Is it enlightening?

In addition to the visualization and accompanying narrative, write an approximately 500 word explanation defending your design choices. This includes (but is not limited to):

  • What is the story?
  • Why did you select this graphical form?
  • What is the role of interactivity? How does it enhance your ability to tell the story and communicate the data?

Submission details

Deploy your app on shinyapps.io and include a link to it in your submission on github classroom. Include your design explanation in a separate tab in the shiny app.


  1. Though with far less detail ↩︎

  2. You could also rewrite it to directly import from Google Sheets using the googlesheets package, making it fully reproducible. ↩︎