Skip to content

Data Manipulation with dplyr

Run the hidden code cell below to import the data used in this course.

Hidden code

Take Notes

Add notes about the concepts you've learned and code cells with code you want to keep.

##instructions. ##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.

Add your notes here

counties_selected %>%
  # Add population_walk containing the total number of people who walk to work 
  mutate(population_walk = population * walk / 100) %>%
  # Count weighted by the new column, sort in descending order
  count(state, wt = population_walk, sort = TRUE)