Skip to content

Commit

Permalink
integrating firm synthesis summary outputs into main dashboard #33
Browse files Browse the repository at this point in the history
  • Loading branch information
ColSmith76 committed Mar 2, 2023
1 parent 4d2d4f6 commit 8b80396
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 23 deletions.
12 changes: 12 additions & 0 deletions lib/scripts/__Master.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
16 changes: 6 additions & 10 deletions lib/scripts/firm_sim.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion lib/scripts/firm_sim_process_inputs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 1 addition & 12 deletions lib/scripts/firm_sim_summary_render.R
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)

}
File renamed without changes.

0 comments on commit 8b80396

Please sign in to comment.