Skip to content

Instantly share code, notes, and snippets.

@MattCowgill
MattCowgill / .block
Last active August 9, 2019 10:53
Reusable Line Chart v2
license: mit
@MattCowgill
MattCowgill / anz_forward_rate.R
Last active May 10, 2022 04:24
ANZ forward cash rate chart replication
library(readrba)
library(tidyverse)
theme_anz <- function(...) {
theme_minimal(...) +
theme(panel.grid.major.x = element_blank(),
panel.grid.minor = element_blank(),
legend.position = "bottom",
legend.direction = "horizontal",
legend.title = element_blank(),
library(readxl)
library(tidyverse)
library(lubridate)
library(janitor)
rents_url <- "https://www.dffh.vic.gov.au/moving-annual-rents-suburb-june-quarter-2021-excel"
rents_loc <- tempfile(fileext = ".xlsx")
download.file(url = rents_url,
destfile = rents_loc,
library(tidyverse)
library(readabs)
library(readxl)
library(lubridate)
hes_file <- download_abs_data_cube("household-expenditure-survey-australia-summary-results",
"do001")
hes_raw <- read_excel(hes_file, sheet = "Table 1.1", range = "A33:H47",
col_names = c("cat", "1984", "1988–89", "1993–94", "1998–99", "2003–04", "2009–10", "2015–16"))
@MattCowgill
MattCowgill / oecd_inflation.R
Last active October 22, 2022 06:57
Recreate an RBA chart of inflation in key locations
library(OECD)
library(tidyverse)
library(lubridate)
library(countrycode)
oecd_cpi_raw <- get_dataset("PRICES_CPI",
"AUS+CAN+JPN+GBR+USA+EA19.CPALTT01.GY.Q+M")
oecd_cpi <- oecd_cpi_raw |>
janitor::clean_names() |>
library(tidyverse)
library(readrba)
forecasts <- rba_forecasts()
latest_two <- forecasts |>
filter(forecast_date %in% c(max(forecast_date),
max(forecast_date) - months(3)))
latest_two |>
library(tidyverse)
library(readabs)
vac_raw <- read_abs_series("A85389466F")
ur_raw <- read_abs_series("A84423050A")
ur <- ur_raw |>
mutate(value = slider::slide_mean(value, before = 2L)) |>
select(date, ur = value)
# This code provides a way to download table(s) from the Estimate Dwelling Stock
# release, which has not (yet) been added to the ABS Time Series Directory
# and therefore cannot be loaded by readabs::read_abs()
get_dwell_table <- function(table_no = 1, path = tempdir()) {
table_no <- match.arg(as.character(table_no), as.character(1:9))
filename <- paste0("87010", table_no, ".xlsx")
file <- readabs::download_abs_data_cube("estimated-dwelling-stock",
filename,
path = path)
This file has been truncated, but you can view the full file.
c("JUN-16", "SEP-16", "DEC-16", "MAR-17", "JUN-17", "SEP-17", "DEC-17", "MAR-18", "JUN-18", "SEP-18", "DEC-18", "MAR-19", "JUN-19", "SEP-19", "DEC-19", "MAR-20", "JUN-20", "SEP-20", "DEC-20", "MAR-21", "JUN-21", "SEP-21", "DEC-21", "MAR-22", "JUN-22", "JUN-16", "SEP-16", "DEC-16", "MAR-17", "JUN-17", "SEP-17", "DEC-17", "MAR-18", "JUN-18", "SEP-18", "DEC-18", "MAR-19", "JUN-19", "SEP-19", "DEC-19", "MAR-20", "JUN-20", "SEP-20", "DEC-20", "MAR-21", "JUN-21", "SEP-21", "DEC-21", "MAR-22", "JUN-22",
"JUN-16", "SEP-16", "DEC-16", "MAR-17", "JUN-17", "SEP-17", "DEC-17", "MAR-18", "JUN-18", "SEP-18", "DEC-18", "MAR-19", "JUN-19", "SEP-19", "DEC-19", "MAR-20", "JUN-20", "SEP-20", "DEC-20", "MAR-21", "JUN-21", "SEP-21", "DEC-21", "MAR-22", "JUN-22", "JUN-16", "SEP-16", "DEC-16", "MAR-17", "JUN-17", "SEP-17", "DEC-17", "MAR-18", "JUN-18", "SEP-18", "DEC-18", "MAR-19", "JUN-19", "SEP-19", "DEC-19", "MAR-20", "JUN-20", "SEP-20", "DEC-20", "MAR-21", "JUN-21", "SEP-21", "DEC-21", "MAR-22", "JUN-22", "JUN-16",
"SEP-16",
library(readabs)
path <- file.path(tempdir(), "abs_dwellings")
dir.create(path)
dwellings_sa2_zip <- download_abs_data_cube("estimated-dwelling-stock",
"zip",
path = path)
zip::unzip(dwellings_sa2_zip,