This document presents an analysis of wage, state, and demographic data. The aim is to explore trends, compare union vs. nonunion wages, and understand employment patterns across different states.
Dataset origin: https://github.com/rfordatascience/tidytuesday/blob/master/data/2023/2023-09-05/readme.md
Description of dataset: The datasets “demographics.csv,” “wages.csv,” and “states.csv” offer comprehensive insights into union membership and wage patterns in the United States from 1973 to 2022, with a gap in 1982. Sourced primarily from the Current Population Survey (CPS) and its Outgoing Rotation Group (ORG) Earnings Files, these datasets reflect changes in union membership definitions post-1977. “Demographics.csv” and “states.csv” track union membership, coverage by collective bargaining agreements, and employment metrics in the U.S., broken down by various demographic and state sectors. Key variables include the year, sample size, employment figures, union membership, coverage percentages, and specific sector or demographic group data. In contrast, “wages.csv” delves into wage analysis, providing information on mean hourly earnings, the wage cap, and the union wage premium (both raw and adjusted). This dataset includes detailed variables such as sample size, wages, union and nonunion wage comparisons, and adjustments for worker and job characteristics, excluding imputed earners for accuracy. Each dataset utilizes a double or character class for variables like year, sample size, employment, and state names or abbreviations, offering a robust framework for analyzing union influence on wages and employment across different sectors and demographics in the U.S.
demographics <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/demographics.csv')
## Rows: 1327 Columns: 8
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): facet
## dbl (7): year, sample_size, employment, members, covered, p_members, p_covered
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
wages <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/wages.csv')
## Rows: 1247 Columns: 9
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): facet
## dbl (8): year, sample_size, wage, at_cap, union_wage, nonunion_wage, union_w...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
states <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2023/2023-09-05/states.csv')
## Rows: 10200 Columns: 11
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): state, sector, state_abbreviation
## dbl (8): state_census_code, observations, employment, members, covered, p_me...
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Here we will create two filtered datasets by date:
wages: Year greater than 2000
States: Year greater than 2000
filtered_wages <- wages[wages$year >= 2000, ]
filtered_states <- states[states$year >= 2000, ]
filtered_demographics <- demographics[demographics$year >= 2000, ]
We will merge the states and wages as these make the most sense for merging in terms of relation.
merged_data <- merge(states, wages, by = "year", all.x = TRUE)
We set the created filtered tables to ‘data.table’ format in order to be able to use them in ggplot.
setDT(filtered_wages)
setDT(filtered_states)
setDT(filtered_demographics)
wage_trends <- filtered_wages[, list(mean_union_wage = mean(union_wage, na.rm = TRUE),
mean_nonunion_wage = mean(nonunion_wage, na.rm = TRUE)), by = list(year)]
membership_trends <- filtered_demographics[, list(average_p_members = mean(p_members, na.rm = TRUE)), by = year]
# rescaling 'members' columns
merged_data$members_scaled <- merged_data$members * 100
average_wage_by_year <- filtered_wages[, list(average_wage = (mean(union_wage, na.rm = TRUE) +
mean(nonunion_wage, na.rm = TRUE)) / 2),
by = list(year)]
library(ggplot2)
ggplot(average_wage_by_year, aes(x = year, y = average_wage)) +
geom_line() +
labs(title = "Average Wage Trends Over Years", x = "Year", y = "Average Wage") +
theme_minimal() +
scale_color_brewer(palette = "Set1")
The plot displays the trend of average wages over a span of two decades, starting from the year 2000 up to the year 2020. It shows a clear upward trajectory in average wages as time progresses. The x-axis represents the years, while the y-axis denotes the average wage figures. The line graph is steadily ascending, indicating that on average, wages have increased over the 20-year period.
ggplot(filtered_wages, aes(x = factor(year), y = union_wage)) +
geom_boxplot() +
labs(title = "Union Wages Comparison by Year", x = "Year", y = "Union Wage") +
theme_minimal()
There is a general upward trend in the median of union wages over the years, as indicated by the median line within each box shifting upwards. The increasing height of the boxes and the lengthening of the whiskers over time suggest that the range and the variability of the wages are also increasing. Outliers are present in several years, showing that there were wages that deviated significantly from the rest.
# Calculate the scaled members
merged_data$members_scaled <- merged_data$members * 100
# Create the plot
ggplot() +
geom_bar(data = states, aes(x = state, y = employment), stat = "identity", fill = "steelblue", alpha = 0.7) +
geom_line(data = merged_data, aes(x = state, y = members_scaled, group = state), color = "red") +
labs(title = "Employment Trends by State (scaled)", x = "State", y = "Employment/union members", y.sec = "Members (scaled)") +
theme_minimal() +
scale_fill_brewer(palette = "Pastel1") +
coord_flip() +
scale_y_continuous(sec.axis = sec_axis(~ . / 100, name = "Members"))
This graph shows the prevalence of union membership among the working population in each state. Albeit one cannot draw firm conclusions from this graph alone, it is apparent that all states have some form of unionship representation. Those that stand out as most prevalent are California, New York and Pennsylvania.
ggplot(wages, aes(x = year)) +
geom_smooth(aes(y = union_wage, color = "Union Wage"), se = FALSE, method = "loess") +
geom_smooth(aes(y = nonunion_wage, color = "Nonunion Wage"), se = FALSE, method = "loess") +
labs(title = "Union vs Nonunion Wage Trends Over Time",
x = "Year", y = "Wage",
color = "Type of Wage") +
theme_minimal(base_size = 14) +
theme(legend.position = "bottom") +
scale_color_manual(values = c("Union Wage" = "blue", "Nonunion Wage" = "green")) +
guides(color = guide_legend(title = "Wage Type"))
## `geom_smooth()` using formula = 'y ~ x'
## `geom_smooth()` using formula = 'y ~ x'
The graph illustrates the comparative wage trends for union and nonunion workers from 1980 to just beyond 2020. Both wage types show a clear upward trend over the four-decade period, with union wages consistently higher than nonunion wages throughout. The gap between the two wage types appears to have remained relatively stable over time, indicating that while both groups have seen wage increases, union workers have maintained a consistent wage advantage.
ggplot(demographics, aes(x = year, y = p_members)) +
geom_area(fill = "lightblue", alpha = 0.5) +
labs(title = "Union Membership Trends Over Time", x = "Year", y = "Percentage of Union Members") +
theme_minimal() +
scale_fill_brewer(palette = "Blues")
The chart presents a clear decline in the percentage of union members among the workforce from 1980 to the present. The graph starts with a higher percentage of union membership in the early 1980s, which appears to be above 20%, and shows a steady, almost linear decrease over the subsequent four decades. By the 2020 endpoint, the percentage has dropped to near or below 5%. This substantial decline suggests a significant shift in the labor market or changes in labor laws and policies that may have affected union membership. The trend could also reflect broader economic shifts, such as the transition from a manufacturing-based economy to a service-oriented one, globalization, increased competition, changes in the political environment, or shifts in worker preferences.
ggplot(states, aes(x = year, y = employment, fill = sector)) +
geom_bar(stat = "identity", position = "stack") +
labs(title = "Employment in Different Sectors Over Time", x = "Year", y = "Employment") +
theme_minimal() +
scale_fill_brewer(palette = "Spectral")
The chart shows the distribution and trends of employment across various sectors from 1990 to around 2020. Private sector jobs, excluding construction and manufacturing, appear to have experienced the most significant growth, showing a consistent upward trend. In contrast, employment in the private manufacturing sector has either remained relatively stable or declined slightly, as evidenced by the shrinking proportion of this sector in the total employment stack over time. Private construction employment shows cyclical patterns, possibly correlating with economic booms and busts, and while it is a smaller segment compared to the other sectors, it also demonstrates growth in the latter years. The public sector employment is represented as well, indicating a steady, modest increase over the decades, although it constitutes a smaller slice of the overall employment pie compared to the private sector.
The analysis of various labor market trends over the past few decades presents a multifaceted picture of the changes in employment, wages, and union representation in the United States.
Starting with wages, there is a consistent rise in average wages between 2000 and 2020, suggesting a healthy wage growth across the board. This increase is mirrored in the specific analysis of union wages, where both the median wage and the variability in wages have been climbing. This could be indicative of an overall improvement in labor market conditions, possibly driven by economic growth, inflation adjustments, and productivity increases.
However, the stability of the wage gap between union and nonunion workers from 1980 onwards implies that the benefits of union representation in terms of wage levels have persisted, providing union members with a wage premium over nonunion workers. Although there is some scatter in the data, with fluctuations that may reflect sector-specific or regional economic conditions, the wage premium has shown a slight decrease in the last decade, which, if continued, could reduce the financial advantage of being in a union.
The union membership trends offer a more concerning narrative, with a significant and almost linear decline in union membership as a percentage of the workforce from the 1980s to 2020. Starting from levels above 20%, membership has dwindled to around 5% by 2020. This decline is symptomatic of deep structural changes within the economy, such as the shift from manufacturing to services, globalization, competitive pressures, and perhaps changing labor policies and worker sentiment towards unionization.
Employment trends by sector from 1990 to 2020 show a significant increase in private non-manufacturing and non-construction jobs, suggesting a shift towards a service-driven economy. Manufacturing employment has either stabilized or decreased slightly, while construction employment has fluctuated with economic cycles. Public sector employment, although smaller compared to the private sector, has seen a steady increase.
In summary, the labor market has seen positive trends in wage growth but a concerning decline in union representation. The persistent wage gap between union and nonunion workers, alongside the overall increase in employment, particularly in the private service sector, outlines an evolving economy. The gradual decline in the union wage premium and the sharp decrease in union membership may have far-reaching implications for the labor market, potentially affecting wage negotiations, worker rights, and the overall dynamics between employers and employees.