BaşlayınÜcretsiz Başlayın

Mapping change in voter turnout

You already saw that voter turnout increased in nearly every state in the 2018 midterm elections compared to the 2014 midterms. In this exercise, your task is to map the change in voter turnout between these two midterm elections.

The turnout data frame, dplyr, and plotly have already been loaded for you.

Bu egzersiz

Interactive Data Visualization with plotly in R

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Use mutate() to add a change column to turnout, which is calculated by as the difference between the turnout in 2018 (turnout2018) and 2014 (turnout2014).
  • Use plot_geo() and add_trace() to create a choropleth map of the change in voter turnout by state, mapping change to z and state.abbr to locations.
  • Restrict the scope of the map to the 'usa' using layout().

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Create a choropleth map of the change in voter turnout from 2014 to 2018
turnout %>%
  ___(___) %>%
  ___(locationmode = 'USA-states') %>%
  ___(___, ___) %>%
  ___(geo = ___)
Kodu Düzenle ve Çalıştır