ComeçarComece de graça

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 exercício faz parte do curso

Inference for Categorical Data in R

Ver curso

Instruções do exercício

  • 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.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# 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
___ %>%
  ___(___ > ___)
Editar e executar o código