Skip to content

Instantly share code, notes, and snippets.

library(readxl)
library(tidyverse)
library(geomtextpath)
library(seektheme)
library(patchwork)
madd_url <- "https://www.rug.nl/ggdc/historicaldevelopment/maddison/data/mpd2020.xlsx"
madd_file <- tempfile(fileext = ".xlsx")
download.file(madd_url, madd_file, mode = "wb")
library(readxl)
library(tidyverse)
library(ggdirectlabel)
library(patchwork)
madd_url <- "https://www.rug.nl/ggdc/historicaldevelopment/maddison/data/mpd2020.xlsx"
madd_file <- tempfile(fileext = ".xlsx")
download.file(madd_url, madd_file, mode = "wb")
madd_data <- read_excel(madd_file, sheet = "Full data")
library(readabs) # Need dev version: remotes::install_github("mattcowgill/readabs")
library(tidyverse)
get_ur <- function(release_date = "latest",
series_id = "A84423050A") {
raw <- read_abs_series(series_id = series_id,
release_date = release_date) |>
select(date, series_id, value)
if (release_date == "latest") {
library(readabs) # Need dev version: remotes::install_github("mattcowgill/readabs")
library(tidyverse)
get_ur <- function(release_date = "latest",
series_id = "A84423050A") {
raw <- read_abs_series(series_id = series_id,
release_date = release_date) |>
select(date, series_id, value)
if (release_date == "latest") {
library(tidyverse)
library(ggdirectlabel) # remotes::install_github("MattCowgill/ggdirectlabel")
library(readabs)
read_lfs_datacube <- function(cube,
catalogue_string = "labour-force-australia-detailed",
update_date = Sys.Date()) {
file <- download_abs_data_cube(
catalogue_string = catalogue_string,
cube = cube
library(tidyverse)
library(readabs)
library(data.table)
uq2a_dt <- download_abs_data_cube(catalogue_string = "labour-force-australia-detailed",
cube = "UQ2a") |>
readxl::read_excel(sheet = "Data 1",
skip = 3) |>
janitor::clean_names() |>
as.data.table()
@MattCowgill
MattCowgill / scrape_rba_monpol.R
Last active December 8, 2022 23:27
A function to scrape the full text of Reserve Bank of Australia monetary policy decisions
library(rvest)
library(tidyverse)
#' Scrape RBA monetary policy decision media releases in a tidy tibble
#' @param min_year If `NULL` (the default), all releases will be scraped. If a
#' year is specified (eg. `2015`), only releases from that year onwards will be
#' scraped.
#' @author Matt Cowgill
#' @examples
#' all_decisions <- scrape_monpol_decisions()
library(readabs)
library(tidyverse)
ur <- read_abs_series("A84423050A") |>
select(date, ur = value)
dec_jan_moves <- ur |>
mutate(diff = ur - lag(ur, n = 1L, order_by = date)) |>
filter(month(date) == 1L) |>
mutate(is_latest = if_else(date == max(date), "Jan '23", "Other Januaries since 1979"))
# Estimate confidence intervals around RBA forecasts
# As per https://www.rba.gov.au/publications/rdp/2012/pdf/rdp2012-07.pdf
library(tidyverse)
library(readabs)
library(readrba)
library(tsibble)
raw_forecasts <- read_forecasts()
raw_actual_ur <- read_abs_series("A84423050A")
library(tidyverse)
library(readabs)
# This data contains groups, sub-groups, and expenditure classes
cpi_t13 <- read_abs("6401.0", "13")
# Fetch a list of expenditure classes, as we want to filter to just those
cpi_t14 <- read_abs("6401.0", 14)
exp_classes <- cpi_t14 |>