Intial commit. Pulling multipliers

This commit is contained in:
Alex Gebben Work 2026-08-06 17:12:14 -06:00
parent 2f3a353e26
commit 793c8f734f

21
Tapestry.r Normal file
View File

@ -0,0 +1,21 @@
library(tidyverse)
library(readxl)
GET_MULTIPLIERS <- function(STATE,YEAR=2024,VERSION='1.5.6'){
FILE <- paste0(STATE,"_",YEAR,"_SAM_v",VERSION,"/",STATE,"_leontief_",YEAR,".xlsx")
TYPE1 <- read_xlsx(FILE,'I-Ainv_type1')
TYPE2 <- read_xlsx(FILE,'I-Ainv_type2')
NROW1 <- nrow(TYPE1)
NROW2 <- nrow(TYPE2)
NAMES <- strsplit(colnames(TYPE1[NROW1,2:NROW1]),"_") %>% unlist
NAICS <- NAMES[seq(1,976,by=2)]
Industry_Name <- NAMES[seq(2,976,by=2)]
Indirect <- as.numeric(TYPE1[NROW1,2:NROW1])
Induced <- as.numeric(TYPE2[NROW2,2:(NROW2-6)])
return(cbind(NAICS,Industry_Name,Indirect,Induced) %>% as_tibble %>% mutate(Indirect=as.numeric(Indirect),Induced=as.numeric(Induced)) %>% mutate(State=STATE,Total=Induced,Induced=Induced-Indirect,Indirect=Indirect-1) %>% select(State,everything()))
}
ALL <- full_join(full_join(GET_MULTIPLIERS("Arizona"),GET_MULTIPLIERS("Arkansas")),GET_MULTIPLIERS("California")) %>% full_join(GET_MULTIPLIERS("Wyoming"))
ggplot(ALL,aes(x=State,y=Total,color=State)) + geom_boxplot()