Exercise

Breaking it down by province

Although the overall vote totals are the most important, you can dig deeper into this data by utilizing the geographic information. In this exercise, you'll see how the results differed by province.

Did Ahmadinejad win throughout the country, or were there provinces where the second place candidate came out on top? To answer this question, start by creating a province-level dataset.

Instructions

100 XP
  • Start with iran, group by province, then summarize with two variables: the sum of the votes of the first place candidate and the sum of the votes of the second place candidate. Name each new column with the name of the candidate.
  • Inspect province_totals.
  • Filter province_totals for every row where the second-place candidate got more votes than the first-place candidate.