107 lines
7.9 KiB
R
107 lines
7.9 KiB
R
library(tidyverse)
|
|
#install.packages("paletteer")
|
|
|
|
library(scales)
|
|
library(paletteer)
|
|
DATA_DIR <- 'Results/Tax_PI/'
|
|
OUTPUT_DIR <- './Results/Figures/Tax_PI'
|
|
dir.create(OUTPUT_DIR,recursive=TRUE,showWarnings=FALSE)
|
|
######################Employments
|
|
EMPLOY <- read_csv(paste0(DATA_DIR,"Direct, Indirect, and Induced -Employment.csv" ),skip=5) %>% pivot_longer(c(-Category,-Units),names_to="Year")
|
|
try(EMPLOY <- EMPLOY %>% mutate(value=parse_number(value)))
|
|
try(EMPLOY <- EMPLOY %>% mutate(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(2029,seq(2025,2060,by=2)))+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")+scale_y_continuous(labels = scales::comma,breaks=seq(0,3000,by=250))
|
|
|
|
png(paste0(OUTPUT_DIR,"Job_plot.png" ) , units = "in", width = 11, height = 8, res = 600)
|
|
JOB_PLOT
|
|
dev.off()
|
|
#JOB_PLOT
|
|
###################Output graph
|
|
OUTPUT <- read_csv(paste0(DATA_DIR,"Direct, Indirect, and Induced -Output.csv" ),skip=5) %>% pivot_longer(c(-Category,-Units),names_to="Year")
|
|
try(OUTPUT <- OUTPUT %>% mutate(value=parse_number(value)))
|
|
try(OUTPUT <- OUTPUT %>% mutate(Year=parse_number(Year)))
|
|
|
|
|
|
#OUTPUT_NUM <- OUTPUT %>% filter(Units=='Thousands of Fixed (2025) Dollars') %>% select(-Units,Output=value) %>% filter(Year>=2028) %>% mutate(Output=Output/1000)
|
|
OUTPUT_NUM <- OUTPUT %>% filter(Units=='Millions of Fixed (2022) Dollars') %>% select(-Units,Output=value) %>% filter(Year>=2028) %>% mutate(Output=Output)
|
|
|
|
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)
|
|
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(2028,seq(2025,2060,by=5)))+scale_fill_manual(values=COLORS)+geom_line(data=OUTPUT_NUM %>% filter(Category=="Total"),size=1)
|
|
OUTPUT_PLOT
|
|
#+geom_text(data=df,aes(label = text), vjust = "inward", hjust = "inward")+theme(legend.position = "top")
|
|
png(paste0(OUTPUT_DIR,"Output_plot.png"), units = "in", width = 10, height = 8, res = 600)
|
|
OUTPUT_PLOT
|
|
dev.off()
|
|
###################
|
|
INDUSTRY_JOBS <- read_csv(paste0(DATA_DIR,'Employment- By Industry - Employment by Industry.csv'),skip=5) %>% pivot_longer(c(-Industry,-Units),names_to="Year") %>% mutate(Jobs=parse_number(value),Year=parse_number(Year)) %>% select(-value) %>% filter(Industry!='All Industries') %>% select(-Units) %>% filter(Year>=2029)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Data processing, hosting, and related services; Other information services',"Data processing",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Professional, scientific, and technical services',"Technical services",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Administrative and support services',"Administrative services",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='State and Local Government',"Government",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Food services and drinking places',"Restaurants",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Other transportation equipment manufacturing',"Equipment manufacturing",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Repair and maintenance',"Maintenance",INDUSTRY_JOBS$Industry)
|
|
INDUSTRY_JOBS$Industry <- ifelse(INDUSTRY_JOBS$Industry=='Utilities',"Energy Production",INDUSTRY_JOBS$Industry)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
INDUSTRY_JOBS <- INDUSTRY_JOBS %>% group_by(Year) %>% mutate(Rank=rank(-Jobs)) %>% mutate(Rank=ifelse(Rank>10,11,Rank),Industry=ifelse(Rank==11,"Other",Industry)) %>% group_by(Year,Industry,Rank) %>% summarize(Jobs=sum(Jobs)) %>% ungroup(Industry,Rank) %>% arrange(Year,Rank)
|
|
|
|
ORDER <- c(INDUSTRY_JOBS %>% filter(Industry!='Other') %>% group_by(Industry) %>% summarize(MEAN=mean(Jobs)) %>% arrange(desc(MEAN)) %>% pull(Industry) %>% unique,"Other")
|
|
INDUSTRY_JOBS$Industry <- factor(INDUSTRY_JOBS$Industry,levels=ORDER)
|
|
|
|
JOB_TYPE_PLOT <- ggplot(INDUSTRY_JOBS ,aes(x=Year,y=Jobs,fill=Industry))+geom_bar(stat='identity')+ paletteer::scale_fill_paletteer_d("colorBlindness::Blue2DarkRed18Steps")+theme_bw()+theme(text = element_text(size = 20),legend.position = "top")+guides(fill=guide_legend(nrow=2,byrow=TRUE)) +scale_x_continuous(breaks=seq(2029,2060,by=1))+scale_y_continuous(labels = scales::comma,breaks=seq(0,3000,by=250))
|
|
png(paste0(OUTPUT_DIR,"Job_Dist_Plot.png"), units = "in", width = 22, height = 16, res = 600)
|
|
JOB_TYPE_PLOT
|
|
dev.off()
|
|
|
|
|
|
JOB_FACET <- ggplot(INDUSTRY_JOBS %>% filter(Year %in% c(2032,2033,2045,2060)),aes(x=factor(Year),y=Jobs,fill=factor(Year)))+geom_bar(stat='identity',width=0.99)+facet_wrap(.~Industry)+theme_bw()+xlab("Year")+theme(text=element_text(size=16),legend.position="top",palette.colour.discrete=c("darkslategray1","darkslategray3","darkorchid1","darkorchid3" ))+scale_fill_discrete(name = "Year") +scale_y_continuous(labels = scales::comma,breaks=seq(0,1000,by=100))
|
|
JOB_FACET
|
|
|
|
png(paste0(OUTPUT_DIR,"Job_Facet_Plot.png"), units = "in", width = 11, height = 11, res = 600)
|
|
JOB_FACET
|
|
dev.off()
|
|
|
|
##################GDP
|
|
GDP <- read_csv(paste0(DATA_DIR,'Gross Domestic Product - By Component - GDP Components.csv'),skip=5)%>% select(-Units) %>% pivot_longer(c(-Category),names_to="Year") %>% mutate(value=parse_number(value)/1000,Year=parse_number(Year)) %>% filter(Year>=2029)
|
|
GDP <- GDP %>% filter(Category %in% c('Gross Domestic Product (GDP)','Consumption','Investment','Change in Private Inventories','Net Trade','Government Spending','Exogenous Final Demand'))
|
|
GDP_TOTAL <- GDP %>% filter(Category=='Gross Domestic Product (GDP)') %>% select(-Category) %>% rename(GDP=value)
|
|
GDP <- GDP %>% filter(Category!='Gross Domestic Product (GDP)')
|
|
GDP_PLOT <- ggplot(GDP_TOTAL ,aes(x=Year,y=GDP))+geom_line(linewidth=1,color='slateblue')+theme_bw()+theme(text=element_text(size=16),legend.position="top")+ylab("Wyoming GDP (Million USD)")+scale_x_continuous(breaks=c(seq(2030,2060,by=2)))+scale_y_continuous(breaks=seq(0,500,by=25))
|
|
|
|
png(paste0(OUTPUT_DIR,"GDP_Plot.png"), units = "in", width = 11, height = 8, res = 600)
|
|
GDP_PLOT
|
|
dev.off()
|
|
|