Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Created May 31, 2023 03:18
Show Gist options
  • Save MattCowgill/13568d03180bf20f068b066c3bfd75bd to your computer and use it in GitHub Desktop.
Save MattCowgill/13568d03180bf20f068b066c3bfd75bd to your computer and use it in GitHub Desktop.
library(readabs)
library(tidyverse)
library(readxl)
theme_set(theme_minimal() +
theme(panel.grid = element_blank(),
axis.ticks = element_line(),
axis.line.x = element_line()))
eeh_path <- download_abs_data_cube("employee-earnings-and-hours-australia",
"003")
eeh_raw <- eeh_path |>
read_excel(range = "Table_3!A5:D32") |>
filter(!is.na(Award)) |>
rename(income_range = 1)
eeh_long <- eeh_raw |>
pivot_longer(!income_range,
names_to = "method") |>
mutate(income_lower = strayr::parse_income_range(income_range),
income_lower = if_else(income_range == "Under $200", 0, income_lower),
income_range = str_remove_all(income_range, " under"),
income_range = str_replace_all(income_range, "Under ", "<"),
income_range = str_replace_all(income_range, " and over", "+"),
method = factor(method, levels = c("Award",
"Individual arrangement",
"Collective agreement")))
eeh_long |>
ggplot(aes(x = reorder(income_range,
income_lower),
y = value, fill = method)) +
geom_col(position = "fill",
width = 0.99,
linewidth = 0) +
geom_text(data = ~filter(., income_lower == 1300) |>
arrange(desc(method)) |>
mutate(y = (cumsum(value) - (value/ 2)) / sum(value)),
aes(label = method,
y = y),
size = 16 / .pt,
col = "white") +
scale_x_discrete(labels = \(x) str_wrap(x, 9),
breaks = \(x) x[seq_along(x) %% 2 == 1],
guide = guide_axis(n.dodge = 2)) +
scale_y_continuous(expand = expansion(0),
labels = scales::percent) +
labs(x = "Weekly earnings",
subtitle = "Method of pay setting by earnings range",
title = "Collective agreements are more common in upper-middle pay ranges",
caption = "Source: ABS EEH 2021") +
theme(legend.position = "none",
axis.title.y = element_blank())
@MattCowgill
Copy link
Author

pay_method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment