# Read code until forecast object is created
# Setup -------------------------------------------------------------------
Sys.setenv(TZ = 'UTC')
librarian::shelf(
"tidyverse",
"zoo",
"TTR",
"tsibble",
"lubridate",
"glue",
"fim",
"dplyover",
gt
)
options(digits = 4)
options(scipen = 20)
devtools::load_all()
contributions <- readr::read_rds(here::here("data/contributions.rds"))
# Set dates for current and previous months
month_year <- glue('{format.Date(today(), "%m")}-{year(today())}')
last_month_year <- glue('{format.Date(today()-months(1), "%m")}-{year(today())}')
if(!dir.exists(glue('results/{month_year}'))) {
dir.create(glue('results/{month_year}'))
}
# Wrangle data ------------------------------------------------------------
# Since BEA put all CARES act grants to S&L in Q2 2020 we need to
# override the historical data and spread it out based on our best guess
# for when the money was spent.
overrides <- readxl::read_xlsx(here::here('data/forecast.xlsx'),
sheet = 'historical overrides')
forecast <-
readxl::read_xlsx(here::here('data/forecast.xlsx'),
sheet = 'forecast') %>%
select(-15:-17, -name) %>%
pivot_longer(-variable) %>%
pivot_wider(names_from = 'variable',
values_from = 'value') %>%
rename(date = name) %>%
mutate(date = yearquarter(date))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.