From 8b803964344381979bfe70fc6a1eecd968462fdf Mon Sep 17 00:00:00 2001 From: Colin Smith Date: Thu, 2 Mar 2023 08:45:37 -0500 Subject: [PATCH] integrating firm synthesis summary outputs into main dashboard #33 --- lib/scripts/__Master.R | 12 ++++++++++++ lib/scripts/firm_sim.R | 16 ++++++---------- lib/scripts/firm_sim_process_inputs.R | 2 +- lib/scripts/firm_sim_summary_render.R | 13 +------------ ...{ft_sim_summary_render.R => ft_sim_summary.R} | 0 5 files changed, 20 insertions(+), 23 deletions(-) rename lib/scripts/{ft_sim_summary_render.R => ft_sim_summary.R} (100%) diff --git a/lib/scripts/__Master.R b/lib/scripts/__Master.R index 78ba9b0..7f25a8c 100644 --- a/lib/scripts/__Master.R +++ b/lib/scripts/__Master.R @@ -190,6 +190,18 @@ if (SCENARIO_RUN_DB) { db_inputs <- new.env() db_build_process_inputs(envir = db_inputs) + + ### TODO integrate the firm synthesis summary into dashboard + # # Data to summarize in dashboard + # # 1. FirmsDomesticUnscaled -- copy of FirmsDomestic table prior to scaling + # # 2. FirmsDomestic -- FirmsDomestic table after scaling, at end of firm syn script + # # 3. emp_control -- input employment control data + # + # # Render the dashboard + # rmarkdown::render(input = "./lib/Dashboard/CMAP_FirmSynthesis_Summary.Rmd", + # output_file = paste0("CMAP_FirmSynthesis_Summary.html"), + # output_dir = SCENARIO_OUTPUT_PATH) + # Generate dashboard and spreadsheet cat("Rendering Freight Model Dashboard and Spreadsheet", "\n") dashboardFileLoc <- suppressWarnings(suppressMessages( diff --git a/lib/scripts/firm_sim.R b/lib/scripts/firm_sim.R index 9984a0b..1575380 100644 --- a/lib/scripts/firm_sim.R +++ b/lib/scripts/firm_sim.R @@ -146,18 +146,14 @@ firm_sim <- function(Establishments) { maxbusid = max(producers$SellerID), writeConsumersIncremental = TRUE) #change to TRUE for production - cat("Firm Synthesis Summary Dashboard", "\n") + cat("Firm Synthesis Summary", "\n") progressUpdate(prop = 9/12, dir = SCENARIO_LOG_PATH) - firms_sum <- firm_synthesis_summary_render(FirmsDomesticUnscaled = FirmsDomesticUnscaled, - FirmsDomestic = FirmsDomestic, - producers = producers, - consumers = consumers, - io = io_list$io, - prefweights = prefweights, - emp_control = emp_control, - c_n6_labels = c_n6_labels, - c_mz_faf_reg = c_mz_faf_reg) + firms_sum <- firm_synthesis_summary(FirmsDomestic = FirmsDomestic, + producers = producers, + consumers = consumers, + io = io_list$io, + prefweights = prefweights) cat("Writing NAICS Market Groups", "\n") diff --git a/lib/scripts/firm_sim_process_inputs.R b/lib/scripts/firm_sim_process_inputs.R index 7eb6516..788d1e6 100644 --- a/lib/scripts/firm_sim_process_inputs.R +++ b/lib/scripts/firm_sim_process_inputs.R @@ -22,7 +22,7 @@ firm_sim_process_inputs <- function(envir) { firm_sim_producers = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_producers.R"), firm_sim_sample_groups = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_sample_groups.R"), firm_sim_scaling = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_scaling.R"), - firm_sim_summary_render = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_summary_render.R"), + firm_sim_summary = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_summary.R"), firm_sim_write_groups = file.path(SYSTEM_SCRIPTS_PATH, "firm_sim_write_groups.R")) loadInputs(files = project.files, envir = envir) diff --git a/lib/scripts/firm_sim_summary_render.R b/lib/scripts/firm_sim_summary_render.R index 64e125a..5c07cd1 100644 --- a/lib/scripts/firm_sim_summary_render.R +++ b/lib/scripts/firm_sim_summary_render.R @@ -1,5 +1,5 @@ # Firm synthesis summary -firm_synthesis_summary_render <- function(FirmsDomesticUnscaled, FirmsDomestic, producers, consumers, io, prefweights, emp_control, c_n6_labels, c_mz_faf_reg) { +firm_synthesis_summary_render <- function(FirmsDomestic, producers, consumers, io, prefweights) { # output summaries sctgcat <- data.table(Commodity_SCTG = prefweights$Commodity_SCTG, @@ -120,17 +120,6 @@ firm_synthesis_summary_render <- function(FirmsDomesticUnscaled, FirmsDomestic, capture.output(print(firms_sum),file=file.path(SCENARIO_OUTPUT_PATH,"firm_syn.txt" )) fwrite(match_summary_naics_sctg, file=file.path(SCENARIO_OUTPUT_PATH,"match_summary_naics_sctg.csv" )) - # Data to summarize in dashboard - # 1. FirmsDomesticUnscaled -- copy of FirmsDomestic table prior to scaling - # 2. FirmsDomestic -- FirmsDomestic table after scaling, at end of firm syn script - # 3. emp_control -- input employment control data - - # Render the dashboard - rmarkdown::render(input = "./lib/Dashboard/CMAP_FirmSynthesis_Summary.Rmd", - output_file = paste0("CMAP_FirmSynthesis_Summary.html"), - output_dir = SCENARIO_OUTPUT_PATH) - - return(firms_sum) } diff --git a/lib/scripts/ft_sim_summary_render.R b/lib/scripts/ft_sim_summary.R similarity index 100% rename from lib/scripts/ft_sim_summary_render.R rename to lib/scripts/ft_sim_summary.R