Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Created February 16, 2024 04:27
Show Gist options
  • Save MattCowgill/0d096653af914f613a2fd7e8519f91c3 to your computer and use it in GitHub Desktop.
Save MattCowgill/0d096653af914f613a2fd7e8519f91c3 to your computer and use it in GitHub Desktop.
library(readabs)
library(tidyverse)
gf_cur <- read_lfs_grossflows("current")
gf_prev <- read_lfs_grossflows("previous")
ur_incoming <- gf_cur |>
filter(lfs_previous == "Incoming rotation group") |>
group_by(lfs_current, date) |>
summarise(value = sum(persons)) |>
pivot_wider(names_from = lfs_current) |>
mutate(ur = Unemployed / (`Employed full-time` + `Employed part-time` + `Unemployed`)) |>
select(date, ur) |>
mutate(series = "incoming")
ur_outgoing <- gf_prev |>
filter(lfs_current == "Outgoing rotation group") |>
group_by(lfs_previous, date) |>
summarise(value = sum(persons)) |>
pivot_wider(names_from = lfs_previous) |>
mutate(ur = Unemployed / (`Employed full-time` + `Employed part-time` + `Unemployed`)) |>
select(date, ur) |>
mutate(series = "outgoing")
ur <- ur_incoming |>
bind_rows(ur_outgoing) |>
pivot_wider(names_from = series,
values_from = ur) |>
mutate(diff = incoming - outgoing,
abs_diff = abs(diff))
ur |>
mutate(pctile = percent_rank(abs_diff)) |>
filter(date == max(date))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment