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.
Este ejercicio forma parte del curso
Inference for Categorical Data in R
Instrucciones del ejercicio
- 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.
Ejercicio interactivo práctico
Prueba este ejercicio y completa el código de muestra.
# 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
___ %>%
___(___ > ___)