Added IMPLAN results clean

This commit is contained in:
alex 2026-08-27 11:04:37 -06:00
parent f87505afd8
commit 6e17ae0ae8
2 changed files with 18 additions and 3 deletions

8
IMPLAN_Visuals.r Normal file
View File

@ -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)))

View File

@ -27,8 +27,15 @@ MAX_VAL <- round(max(EMPLOY_NUM$Employment))
#MAX_VAL #MAX_VAL
COOL_DOWN <- as.numeric(EMPLOY_NUM[5,3]) COOL_DOWN <- as.numeric(EMPLOY_NUM[5,3])
#EMPLOY_NUM #EMPLOY_NUM
#EMPLOY_NUM %>% filter(Category=='Total') %>% arrange(Year)%>% print(n=100) EMPLOY_GRAPH_DATA <- EMPLOY_NUM %>% filter(Category=='Total') %>% mutate(Category=ifelse(Employment<0,"Negative","Positive"))
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)) 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) png(paste0(OUTPUT_DIR,"Job_plot.png" ) , units = "in", width = 11, height = 8, res = 600)
JOB_PLOT JOB_PLOT
@ -41,7 +48,7 @@ OUTPUT_NUM
OUTPUT_NUM$Category <- gsub(" Output","",OUTPUT_NUM$Category) OUTPUT_NUM$Category <- gsub(" Output","",OUTPUT_NUM$Category)
OUTPUT_NUM$Category <- factor(OUTPUT_NUM$Category,levels=rev(c("Direct","Indirect","Induced","Total"))) 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 OUTPUT_PLOT
png(paste0(OUTPUT_DIR,"Output_plot.png"), units = "in", width = 10, height = 8, res = 600) png(paste0(OUTPUT_DIR,"Output_plot.png"), units = "in", width = 10, height = 8, res = 600)