Skip to content

Instantly share code, notes, and snippets.

@JoFAM
Last active April 10, 2018 17:23
Show Gist options
  • Save JoFAM/ca55b0f5c6462f90e199ff7e5016266e to your computer and use it in GitHub Desktop.
Save JoFAM/ca55b0f5c6462f90e199ff7e5016266e to your computer and use it in GitHub Desktop.
Code to produce comparison of wage gap based on OECD data.
library(OECD)
library(dplyr)
library(ggplot2)
## Get the latest OECD data on decile ratios of gross earnings.
## This is the dataset that contains information on wage gaps.
oecdData <- get_dataset("DEC_I")
## Prepare the plot data
gwg <-
oecdData %>%
filter(SERIES == "GWG")
latestgwg <-
filter(gwg, obsTime == "2015")
# Most complete latest data is from 2015
## Comparison of the latest data between my country, the US and the OECD average.
ggplot(latestgwg) +
geom_bar(aes(x = reorder(COUNTRY, -obsValue), y = obsValue),
stat = "identity") +
theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)) +
geom_bar(data = filter(latestgwg, COUNTRY %in% c("USA","BEL", "OECD")),
mapping = aes(x = COUNTRY, y = obsValue, fill = COUNTRY),
stat = "identity") +
labs(x = "Country", y = "Difference M-F as % of median male income")
## Comparison of the trends
ggplot(gwg,aes(x = as.numeric(obsTime), y = obsValue)) +
geom_line(aes(group = COUNTRY), color = "grey") +
labs(x = "Year", y = "Difference M-F as % of median male income") +
geom_line(data = filter(gwg, COUNTRY %in% c("USA","BEL", "OECD")),
mapping = aes( color = COUNTRY),
lwd = 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment