Aan de slagGa gratis aan de slag

Extracting the first digit II

There are different levels at which we could consider looking at vote totals. We could look at precincts, or counties, or states, and each level might give us a slightly different picture of what's going on.

For this analysis, look at totals at the county level in Iowa and focus on the votes for the two major party candidates: Republicans Trump / Pence and Democrats Clinton / Kaine.

Deze oefening maakt deel uit van de cursus

Inference for Categorical Data in R

Cursus bekijken

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Get Iowa county vote totals
iowa_county <- ___ %>%
  # Filter for rep/dem
  ___(candidate %in% c(___, ___)) %>%
  # Group by county
  ___
  # Compute total votes in each county
  ___(dem_rep_votes = ___)
  
# See the result
iowa_county
Code bewerken en uitvoeren