Introduction

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.

Data Summary

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

#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
#summary
summary(gender_pay_gap_sub)
      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 structure
str(gender_pay_gap_sub)
'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

Average Income by Gender

# 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")
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

Analysis and Key Findings

I analyzed the average income, age and hours worked by gender. The result indicated the following:

  1. Average Income
  • Males earn an average of $47,730 compared to females’ $31,437. This represents a ~34% gender pay gap.
  1. Age And Hours
  • 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.

Income Distribution by Age

Age Distribution

Plot

Column{data-width=500}

Key observation

  1. Gender Disparities:
  • 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.

Income Distribution Visualization

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:

  1. Distribution Comparison:
  1. Income Disparity:

This visualization clearly demonstrates systematic income inequality between genders, supporting the existence of a gender pay gap in the data set.

Box Plot: Income Distribution by Gender

Box Plot Analysis

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:

  1. Median Income (center line of boxes):
  1. Income Spread:
  1. Gender Gap Evidence:

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.

Conclusion

Key Takeaways

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:

    • Male median incomes are higher than female medians
    • Both genders show similar patterns in outliers (ranging from $100 to $1,000,000)
    • There is significant overlap in income ranges, suggesting that while the gap exists, other factors (such as occupation, education, or experience) may play crucial roles

** Short-term Actions ** :

  • Address working hours disparity (5.4-hour gap)
  • Implement transparent pay scales
  • Regular gender pay audits

** Long-term Strategies **:

  • Industry-specific interventions where gaps are largest
  • Career advancement programs targeting women
  • Work-life balance policies to support equal opportunity

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.

References