IniziaInizia gratis

Mutating and counting

You can combine multiple verbs together to answer increasingly complicated questions of your data. For example: "What are the US states where the most people walk to work?"

You'll use the walk column, which offers a percentage of people in each county that walk to work, to add a new column and count based on it.

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

Questo esercizio fa parte del corso

Data Manipulation with dplyr

Visualizza il corso

Istruzioni dell'esercizio

  • Use mutate() to calculate and add a column called population_walk, containing the total number of people who walk to work in a county.
  • Use a (weighted and sorted) count() to find the total number of people who walk to work in each state.

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

counties_selected %>%
  # Add population_walk containing the total number of people who walk to work 
  ___
  # Count weighted by the new column, sort in descending order
  ___
Modifica ed esegui il codice