НачатьНачать бесплатно

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)

Это упражнение является частью курса

Data Manipulation with dplyr

Посмотреть курс

Инструкции к упражнению

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

Интерактивное практическое упражнение

Попробуйте выполнить это упражнение, дополнив этот пример кода.

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
  ___
Редактировать и запускать код