Enyo/Visuals.r
Alex Gebben Work 87ac709ff7 Updating data
2026-03-17 14:50:42 -06:00

53 lines
3.4 KiB
R

library(tidyverse)
#install.packages("paletteer")
library(paletteer)
DATA_DIR <- 'Results/REMI_Outputs'
OUTPUT_DIR <- './Results/Figures'
dir.create(OUTPUT_DIR,recursive=TRUE,showWarnings=FALSE)
######################Employments
EMPLOY <- read_csv("Results/Direct, Indirect, and Induced -Employment.csv",skip=5) %>% pivot_longer(c(-Category,-Units),names_to="Year") %>% mutate(value=parse_number(value),Year=parse_number(Year))
EMPLOY_NUM <- EMPLOY %>% filter(Units=='Individuals (Jobs)') %>% select(-Units,Employment=value) %>% filter(Year>=2028)
EMPLOY_NUM <- rbind(EMPLOY_NUM %>% filter(!(Year %in% c(2028,2029))) ,EMPLOY_NUM %>% filter(Year==2028) %>% mutate(Year=2029.74),EMPLOY_NUM %>% filter(Year==2029) %>% mutate(Year=2029.75))
EMPLOY_NUM$Category <- gsub(" Employment","",EMPLOY_NUM$Category)
EMPLOY_NUM$Category <- factor(EMPLOY_NUM$Category,levels=rev(c("Direct","Indirect","Induced","Total")))
COLORS <- rev(paletteer_d("fishualize::Alosa_fallax",n=4,direction=1)[-2])
MAX_VAL <- round(max(EMPLOY_NUM$Employment))
COOL_DOWN <- as.numeric(EMPLOY_NUM[5,3])
df <- data.frame(Year=c(2032.5,2034.25,2046,2059.8),Employment=c(MAX_VAL,COOL_DOWN,791+20,743+20),text=c("Peak of 2,530","Stablized at 961","Midpoint of 791","Ends at 743"))
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(2028,seq(2025,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=EMPLOY_NUM %>% filter(Category=="Total"),size=1)+geom_text(data=df,aes(label = text), vjust = "inward", hjust = "inward")+theme(legend.position = "top")
png("Job_plot.png", units = "in", width = 10, height = 8, res = 600)
JOB_PLOT
dev.off()
JOB_PLOT
###################
OUTPUT <- read_csv("Results/Direct, Indirect, and Induced -Output.csv",skip=5) %>% pivot_longer(c(-Category,-Units),names_to="Year") %>% mutate(value=parse_number(value),Year=parse_number(Year))
OUTPUT
OUTPUT_NUM <- OUTPUT %>% filter(Units=='Thousands of Fixed (2025) Dollars') %>% select(-Units,Output=value) %>% filter(Year>=2028) %>% mutate(Output=Output/1000)
OUTPUT_NUM <- rbind(OUTPUT_NUM %>% filter(!(Year %in% c(2028,2029))) ,OUTPUT_NUM %>% filter(Year==2028) %>% mutate(Year=2029.74),OUTPUT_NUM %>% filter(Year==2029) %>% mutate(Year=2029.75))
OUTPUT_NUM %>% filter(Year==2033)
OUTPUT_NUM$Category <- gsub(" Output","",OUTPUT_NUM$Category)
OUTPUT_NUM$Category <- factor(OUTPUT_NUM$Category,levels=rev(c("Direct","Indirect","Induced","Total")))
#COLORS <- rev(paletteer_d("fishualize::Alosa_fallax",n=4,direction=1)[-2])
MAX_VAL <- round(max(OUTPUT_NUM$Output))
COOL_DOWN <- as.numeric(OUTPUT_NUM[5,3])
#COOL_DOWN
#MAX_VAL
#OUTPUT_NUM %>% filter(Year==2060)
df <- data.frame(Year=c(2032.5,2034.25,2059.8),Output=c(MAX_VAL,COOL_DOWN,337),text=c("Peak of $658 Million","Stablized at $273 Million ","Ends at $337 Million"))
#OUTPUT_PLOT <-
OUTPUT_NUM %>% filter(Year==2033)
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(2028,seq(2025,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=OUTPUT_NUM %>% filter(Category=="Total"),size=1)
+geom_text(data=df,aes(label = text), vjust = "inward", hjust = "inward")+theme(legend.position = "top")
png("Output_plot.png", units = "in", width = 10, height = 8, res = 600)
OUTPUT_PLOT
dev.off()