Aan de slagGa gratis aan de slag

Counting citizens by state

You can weigh your count by particular variables rather than finding the number of counties. In this case, you'll find the number of citizens in each state.

counties_selected <- counties %>%
  select(county, region, state, population, citizens)

Deze oefening maakt deel uit van de cursus

Data Manipulation with dplyr

Cursus bekijken

Oefeninstructies

  • Count the number of counties in each state, weighted based on the citizens column, and sorted in descending order.

Praktische interactieve oefening

Probeer deze oefening eens door deze voorbeeldcode in te vullen.

# Find number of counties per state, weighted by citizens, sorted in descending order
counties_selected %>%
  ___
Code bewerken en uitvoeren