Skip to content

Instantly share code, notes, and snippets.

@dholstius
Created November 18, 2019 18:56
Show Gist options
  • Save dholstius/64dcebdc18d39e84ebebc556851666d0 to your computer and use it in GitHub Desktop.
Save dholstius/64dcebdc18d39e84ebebc556851666d0 to your computer and use it in GitHub Desktop.
QA of BY2015 area source forecast
#
# BY2015-area_source-forecast-chart_annual_growth.R
#
# Created 2019-11-18 by dholstius
#
library(inventory)
library(ggtools)
#
# Change this. (Just an example.)
#
STAFF_NAME <- "Sukarn"
#
# Change this too.
#
QA_CATEGORIES <- c(
"#283 Space Heating" = 283)
#
# Import staff-specific crosswalk (cat_id -> gpf_id).
#
xlsx_forecast_crosswalk_data <-
my_dropbox(
"BY2015",
"Work",
"Area Sources",
STAFF_NAME,
str_c("BY2015-area_sources-", STAFF_NAME, ".xlsx")) %>%
read_excel(
sheet = "forecast_crosswalk")
#
# Import shared forecast profiles (CY2015+).
#
xlsx_forecast_profile_data <-
my_dropbox(
"BY2015",
"Work",
"Projections",
"BY2015_forecast_profiles.xlsx") %>%
read_excel(
sheet = "raw")
#
# Filter the crosswalk, then join to the data.
#
chart_data <-
xlsx_forecast_crosswalk_data %>%
filter_categories(
QA_CATEGORIES) %>%
inner_join(
xlsx_forecast_profile_data,
by = "gpf_id",
suffix = c(".crosswalk", ".profile"))
#
# Chart the filtered-and-joined data.
#
chart_data %>%
chart_annual_growth_by(
base_year = CY(2015),
color = category,
flag_years = CY(2020, 2030, 2040),
title = "BY2015: Area Source Forecasts",
subtitle = "Derived from XLSX crosswalk and profile data.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment