Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Last active April 10, 2024 02:43
Show Gist options
  • Save MattCowgill/6be05ed266e7ab87a2082ac42650b359 to your computer and use it in GitHub Desktop.
Save MattCowgill/6be05ed266e7ab87a2082ac42650b359 to your computer and use it in GitHub Desktop.
# Recreate a chart by Ben Phillips on the % of (civilian 15+) adults
# in couple-only households from the ABS Labour Force Survey
# https://x.com/BenPhillips_ANU/status/1777555189568057712
library(readabs)
library(tidyverse)
fm2 <- read_lfs_datacube("fm2")
theme_ben <- function(...) {
theme_minimal(...) %+replace%
theme(
legend.position = "bottom",
panel.grid = element_blank(),
panel.border = element_rect(fill = NA),
axis.ticks = element_line(),
plot.subtitle = element_text(hjust = 0.5,
face = "bold")
)
}
fm2 |>
mutate(pop = employed_full_time_000 +
employed_part_time_000 +
unemployed_total_000 +
not_in_the_labour_force_nilf_000) |>
group_by(date, relationship_in_household) |>
summarise(pop = sum(pop)) |>
mutate(share = pop / sum(pop)) |>
filter(relationship_in_household == "Husband, wife or partner; Without children") |>
mutate(relationship_in_household = "Couple Only") |>
ggplot(aes(x = date, y = share, col = relationship_in_household)) +
geom_line() +
theme_ben() +
scale_y_continuous("% of adult population",
limits = \(x) c(0.2, x[2]),
breaks = seq(0.2, 0.3, 0.02),
labels = scales::percent) +
scale_colour_manual("Relationship in the household",
values = "#2a25d9") +
scale_x_date("",
date_labels = "%Y",
breaks = seq(ymd("1990-01-01"),
ymd("2025-01-01"),
"5 years")) +
labs(subtitle = "Share of adults in Couple Only Relationship ABS LFS Feb24")
ggsave("couple_only_households.png",
width = 25 / 2, height = 19 / 2,
units = "cm",
scale = 1.5,
bg = "white",
dpi = 300)
@MattCowgill
Copy link
Author

couple_only_households

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