Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
Created December 14, 2023 05:10
Show Gist options
  • Save MattCowgill/979999577fe9bdba6d356f3c6dac70d6 to your computer and use it in GitHub Desktop.
Save MattCowgill/979999577fe9bdba6d356f3c6dac70d6 to your computer and use it in GitHub Desktop.
library(readrba)
library(readabs)
library(tidyverse)
library(gganimate)
library(ggdirectlabel)
min_date <- ymd("1990-01-01")
unemp_forecasts <- read_forecasts() |>
filter(
series == "unemp_rate",
date >= min_date
) |>
select(date, forecast_date, value) |>
mutate(series = "RBA forecast")
ur_actual <- read_abs_series("A84423050A") |>
filter(date >= min_date) |>
select(date, value) |>
mutate(series = "Actual")
unemp_comb <- unemp_forecasts |>
bind_rows(ur_actual)
unemp_comb |>
ggplot(aes(x = date, y = value, group = forecast_date, col = series)) +
geom_line(aes(alpha = series,
linewidth = series)) +
geom_richlegend(aes(label = series),
size = 16 / .pt,
family = "Roboto Condensed") +
scale_y_continuous(labels = \(x) paste0(x, "%"),
breaks = seq(0, 20, 1)) +
scale_alpha_manual(values = c("Actual" = 1,
"RBA forecast" = 0.66)) +
scale_linewidth_manual(values = c("Actual" = 1,
"RBA forecast" = 0.5)) +
theme_minimal(base_size = 16,
base_family = "Roboto Condensed") +
theme(legend.position = "none",
axis.title = element_blank(),
panel.grid.minor = element_blank(),
plot.caption = element_text(size = 8)) +
labs(subtitle = "Unemployment rate (Australia), actual and forecast",
caption = "Source: RBA and ABS. Seasonally adjusted. RBA forecasts are for quarter-averages, actual data is monthly.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment