Get startedGet started for free

Calculating the percentage of women in a county

The dataset includes columns for the total number (not percentage) of men and women in each county. You could use this, along with the population variable, to compute the fraction of men (or women) within each county.

In this exercise, you'll select the relevant columns yourself.

This exercise is part of the course

Data Manipulation with dplyr

View Course

Exercise instructions

  • Select the columns state, county, population, men, and women.
  • Add a new variable called proportion_women with the fraction of the county's population made up of women.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

counties_selected <- counties %>%
  # Select the columns state, county, population, men, and women
  ___

counties_selected %>%
  # Calculate proportion_women as the fraction of the population made up of women
  ___
Edit and Run Code