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.
This exercise is part of the course
Inference for Categorical Data in R
Exercise instructions
- 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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Construct province-level dataset
province_totals <- ___ %>%
# Group by province
___ %>%
# Sum up votes for top two candidates
___
# Inspect data frame
province_totals
# Filter for won provinces won by #2
___ %>%
___(___ > ___)