Import data
# csv file
jobs_gender <- readr::read_csv("https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2019/2019-03-05/jobs_gender.csv")
Apply the following dplyr verbs to your data
Filter rows
filter(jobs_gender, year == 1, total_workers == 1)
Arrange rows
arrange(jobs_gender, desc(year), desc(total_workers))
Select columns
select(jobs_gender, total_earnings)
select(jobs_gender, total_earnings, total_earnings_male)
select(jobs_gender, total_earnings, total_earnings_male, total_earnings_female)
Add columns
mutate(jobs_gender,
gain = total_earnings) %>%
# Select total earnings, total male earnings, and total female earnings
select(total_earnings:total_earnings_male, total_earnings_female)
Summarize by groups
jobs_gender %>%
# Group by total earnings
group_by(total_earnings) %>%
# Calculate average male earnings
summarise(average = mean(total_earnings_male, na.rm = TRUE)) %>%
# Sort it
arrange(total_earnings)
jobs_gender %>%
# Group by total earnings
group_by(total_earnings) %>%
# Calculate average male earnings
summarise(average = mean(total_earnings_female, na.rm = TRUE)) %>%
# Sort it
arrange(total_earnings)