From 6e17ae0ae8a40f1cbcdf523ae8d58d3db108adf0 Mon Sep 17 00:00:00 2001 From: alex Date: Thu, 27 Aug 2026 11:04:37 -0600 Subject: [PATCH] Added IMPLAN results clean --- IMPLAN_Visuals.r | 8 ++++++++ Visuals.r | 13 ++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 IMPLAN_Visuals.r diff --git a/IMPLAN_Visuals.r b/IMPLAN_Visuals.r new file mode 100644 index 0000000..3c535bd --- /dev/null +++ b/IMPLAN_Visuals.r @@ -0,0 +1,8 @@ +library(tidyverse) +GET_FILE <- function(YEAR){ +read_csv(paste0("Model_Outputs/IMPLAN/US/US_",YEAR,"/economic_indicators_by_impact.csv")) %>% mutate(year=YEAR) %>% filter(!is.na(Impact)) +} +DATA <- lapply(2028:2035,GET_FILE) %>% bind_rows()%>% rename(Income=`Labor Income`) %>% mutate(Income=parse_number(Income),`Value Added`=parse_number(`Value Added`),Output=parse_number(Output)) +DATA +DATA$Impact <- gsub("3 - ","",gsub("2 - ","",gsub("1 - ","",DATA$Impact))) + diff --git a/Visuals.r b/Visuals.r index a0606dc..db9a4f6 100644 --- a/Visuals.r +++ b/Visuals.r @@ -27,8 +27,15 @@ MAX_VAL <- round(max(EMPLOY_NUM$Employment)) #MAX_VAL COOL_DOWN <- as.numeric(EMPLOY_NUM[5,3]) #EMPLOY_NUM -#EMPLOY_NUM %>% filter(Category=='Total') %>% arrange(Year)%>% print(n=100) -JOB_PLOT <-ggplot(EMPLOY_NUM %>% filter(Category!="Total"),aes(x=Year,y=Employment))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2027,seq(2030,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=EMPLOY_NUM %>% filter(Category=="Total"),linewidth=1)+geom_text(data=df,aes(label = text),size=6, vjust = "inward", hjust = "inward")+theme(text = element_text(size = 20),legend.position = "top")+scale_y_continuous(labels = scales::comma,breaks=seq(-250,10000,by=500)) +EMPLOY_GRAPH_DATA <- EMPLOY_NUM %>% filter(Category=='Total') %>% mutate(Category=ifelse(Employment<0,"Negative","Positive")) +TEMP <- EMPLOY_NUM %>% filter(Category=='Total') %>% filter(Employment<0) %>% mutate(Employment=0,Category="Positive") +EMPLOY_GRAPH_DATA <- rbind(EMPLOY_GRAPH_DATA ,TEMP) +TEMP2 <- EMPLOY_GRAPH_DATA[max(which(EMPLOY_GRAPH_DATA$Employment<0)),] %>% mutate(Year=Year+1,Employment=0) +EMPLOY_GRAPH_DATA <- rbind(EMPLOY_GRAPH_DATA ,TEMP2) +rm(TEMP,TEMP2) + +JOB_PLOT <-ggplot(EMPLOY_GRAPH_DATA ,aes(x=Year,y=Employment))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2027,seq(2030,2060,by=5)))+scale_y_continuous(labels = scales::comma,breaks=seq(-250,10000,by=500)) +scale_fill_manual(values=c("red","blue3"))+theme(legend.position = "none") + png(paste0(OUTPUT_DIR,"Job_plot.png" ) , units = "in", width = 11, height = 8, res = 600) JOB_PLOT @@ -41,7 +48,7 @@ OUTPUT_NUM OUTPUT_NUM$Category <- gsub(" Output","",OUTPUT_NUM$Category) OUTPUT_NUM$Category <- factor(OUTPUT_NUM$Category,levels=rev(c("Direct","Indirect","Induced","Total"))) - OUTPUT_PLOT <- ggplot(OUTPUT_NUM %>% filter(Category!="Total"),aes(x=Year,y=Output))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2027,seq(2030,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=OUTPUT_NUM%>% filter(Category=="Total"),linewidth=1)+theme(text = element_text(size = 20),legend.position = "top")+scale_y_continuous(labels = scales::comma,breaks=seq(0,2000,by=500))+ylab("Economic Output (Million USD)") + OUTPUT_PLOT <- ggplot(OUTPUT_NUM %>% filter(Category!="Total"),aes(x=Year,y=Output))+geom_area(position = "stack",aes(fill=Category,group=Category))+theme_bw()+scale_x_continuous(breaks=c(2027,seq(2030,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=OUTPUT_NUM%>% filter(Category=="Total"),linewidth=1)+theme(text = element_text(size = 20),legend.position = "top")+scale_y_continuous(labels = scales::comma,breaks=seq(0,10000,by=250))+ylab("Economic Output (Million USD)") OUTPUT_PLOT png(paste0(OUTPUT_DIR,"Output_plot.png"), units = "in", width = 10, height = 8, res = 600)