In this project, I analyzed the gender pay gap data set to explore income disparities between genders across different age groups, occupations, and industries. I subset the data set to include year, sex, age, income(incwage), occupation(occ), industries(ind) and hours worked(uhrswork). This analysis aims to highlight trends and insights related to the gender pay gap, ultimately contributing to a better understanding of economic inequalities in the workforce.
In the initial phase, I loaded the data set and selected relevant columns for my analysis.
The key variables include:
Year: The year of the recorded data.
Sex: Gender of the individuals (Male or Female).
Age: Age of the individuals.
Income (incwage): The income earned by the individuals.
Occupation (occ): Job roles held by individuals.
Industry (ind): The sectors in which individuals worked.
Hours Worked (uhrswork): The number of hours worked per week.
#loading the data
gender_pay_gap <- read.csv("gender_pay_gap.csv")
selected_cols <- c("year", "sex", "age", "incwage", "occ", "ind", "uhrswork")
gender_pay_gap_sub <- gender_pay_gap[, selected_cols]
head(gender_pay_gap_sub) year sex age incwage occ ind uhrswork
1 1990 1 58 14200 335 871 35
2 2009 1 28 17680 5120 8660 40
3 1990 1 37 28000 217 380 40
4 1990 1 34 27500 64 740 45
5 1981 1 38 17000 245 798 40
6 1999 1 37 42000 424 910 40
year sex age incwage
Min. :1981 Min. :1.000 Min. :25.00 Min. : 15
1st Qu.:1990 1st Qu.:1.000 1st Qu.:33.00 1st Qu.: 16700
Median :2007 Median :1.000 Median :41.00 Median : 30000
Mean :2003 Mean :1.489 Mean :41.73 Mean : 39762
3rd Qu.:2011 3rd Qu.:2.000 3rd Qu.:50.00 3rd Qu.: 50000
Max. :2013 Max. :2.000 Max. :64.00 Max. :1259999
occ ind uhrswork
Min. : 1 Min. : 10 Min. : 1.00
1st Qu.: 382 1st Qu.: 760 1st Qu.:40.00
Median :1860 Median :4270 Median :40.00
Mean :2787 Mean :4236 Mean :40.58
3rd Qu.:4760 3rd Qu.:7860 3rd Qu.:41.00
Max. :9750 Max. :9590 Max. :99.00
'data.frame': 344287 obs. of 7 variables:
$ year : int 1990 2009 1990 1990 1981 1999 2007 1990 1999 2011 ...
$ sex : int 1 1 1 1 1 1 1 1 1 1 ...
$ age : int 58 28 37 34 38 37 44 32 41 55 ...
$ incwage : num 14200 17680 28000 27500 17000 ...
$ occ : int 335 5120 217 64 245 424 7750 243 308 9620 ...
$ ind : int 871 8660 380 740 798 910 3570 751 410 8190 ...
$ uhrswork: int 35 40 40 45 40 40 80 48 40 40 ...
#change 'sex' to factor
gender_pay_gap_sub$sex <- factor(gender_pay_gap_sub$sex, levels = c(1, 2), labels = c("Male", "Female"))
#checking for missing values
colSums(is.na(gender_pay_gap_sub)) year sex age incwage occ ind uhrswork
0 0 0 0 0 0 0
After reviewing the data set’s structure and summary statistics, I changed the ‘sex’ variable to factor for better visualization. I also checked for missing values that could affect my analysis.
Column{data-width=600} # Analyze and Visualize
# Create and display the summary table
gender_summary <- gender_pay_gap_sub %>%
group_by(sex) %>%
summarise(
avg_income = mean(incwage, na.rm = TRUE),
avg_age = mean(age, na.rm = TRUE),
avg_hours = mean(uhrswork, na.rm = TRUE)
)
# Display the summary table with a caption
gender_summary %>%
knitr::kable(caption = "Average Income by Gender")| sex | avg_income | avg_age | avg_hours |
|---|---|---|---|
| Male | 47729.86 | 41.58043 | 43.23701 |
| Female | 31436.95 | 41.89519 | 37.79643 |
I analyzed the average income, age and hours worked by gender. The result indicated the following:
Both genders have similar average ages (Male: 41.6, Female: 41.9 years)
Males work on average 5.4 more hours weekly (43.2 vs 37.8 hours)
Summary: The findings highlight a persistent gender pay gap and differences in work hours, which could be contributing factors. Despite similar average ages, males tend to work longer hours and earn significantly more, underscoring structural inequalities.
Column{data-width=500}
Male distribution (lightblue) shows consistently higher counts at higher income levels
Female distribution (pink) is shifted leftward, indicating lower average earnings
The gap is most pronounced in income ranges above $50,000.
The histogram reveals clear gender-based income inequality, with males generally earning higher wages than females.
This disparity is particularly evident in higher income brackets, suggesting potential structural barriers to women’s advancement into higher-paying positions. The log-normal distribution indicates that while most workers earn moderate incomes, there’s a significant tail of high earners where male representation dominates.
To further explore income disparities, I created a histogram illustrating the income distribution by gender. I applied a logarithmic scale to the x-axis to better visualize the variations in income, allowing for a more insightful analysis of the income distribution. Here’s a focused analysis of the gender pay gap from the plot:
This visualization clearly demonstrates systematic income inequality between genders, supporting the existence of a gender pay gap in the data set.
In addition to the histogram, I generated a box plot to provide a visual summary of income distribution by gender.
Here’s a focused analysis of the box plot comparing gender income distributions:
This box plot shows a more subtle gender pay gap than the previous histogram, while also revealing similar patterns of outliers and overall income ranges between genders.
In this analysis, I have explored the gender pay gap using comprehensive income data across various demographics. The key findings reveal persistent wage disparities:
The income distribution histogram clearly demonstrates systematic inequality, with the male income distribution (blue) consistently shifted toward higher earnings compared to the female distribution (pink), particularly in the $50,000+ range.
Box plot analysis reveals structural wage differences where:
** Short-term Actions ** :
** Long-term Strategies **:
These findings underscore the importance of continued efforts to achieve wage equality and highlight the need for targeted interventions to create a more equitable workplace environment.
fedesoriano. (2022). Gender Pay Gap Dataset [Data set]. Kaggle. https://www.kaggle.com/datasets/fedesoriano/gender-pay-gap-dataset
U.S. Bureau of Labor Statistics. (2022). Current Population Survey (CPS). https://www.bls.gov/cps/
Blau, F. D., & Kahn, L. M. (2017). The gender wage gap: Extent, trends, and explanations. Journal of Economic Literature, 55(3), 789-865. https://doi.org/10.1257/jel.20160995
Bertrand, M. (2020). Gender in the twenty-first century. AEA Papers and Proceedings, 110, 1-24. https://doi.org/10.1257/pandp.20201126