Summary

Summary stats for all CBSAs

data <- read_csv("all_cbsa_summary.csv")
## Rows: 9400 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): avg_eal_tercile, NAME
## dbl (8): archive_version_year, CBSAFP, rows, with_parent_number, mean_employ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
plot1 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,rows,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Number of Businesses")
plot2 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,mean_employees,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Mean employees")
plot3 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,mean_year_established,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Mean year established")
plot4 <- data %>% mutate(pct_with_parent=with_parent_number/rows) %>% ggplot()+
  geom_line(aes(archive_version_year,pct_with_parent,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("% with parent")

ggplotly(plot1)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot2) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot3) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot4) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))

Summary (Top 100)

Summarys stats for the top 100 CBSAs

data <- read_csv("all_cbsa_summary_100.csv")
## Rows: 1000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): avg_eal_tercile, NAME
## dbl (8): archive_version_year, CBSAFP, rows, with_parent_number, mean_employ...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
plot1 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,rows,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Number of Businesses")
plot2 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,mean_employees,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Mean employees")
plot3 <- data %>% ggplot()+
  geom_line(aes(archive_version_year,mean_year_established,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("Mean year established")
plot4 <- data %>% mutate(pct_with_parent=with_parent_number/rows) %>% ggplot()+
  geom_line(aes(archive_version_year,pct_with_parent,color=NAME),alpha=0.5)+
  facet_wrap(~avg_eal_tercile,ncol =2)+
  ggtitle("% with parent")

ggplotly(plot1)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot2) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot3) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot4) %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))

Births Deaths Entries Exits - All by Risk

Births, deaths, entries and exits by risk Births are when the abi doesn’t exist the past year Deaths are when the abi doesn’t exist the next year

Entries are when the CBSA is different than the past year and the past year’s CBSA isn’t null Exits are when the CBSA is different than the past year and the next years’s CBSA isn’t null

## Rows: 1000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
##  archive_version_year     CBSAFP          entry             exit       
##  Min.   :2013         Min.   :10420   Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         1st Qu.:19348   1st Qu.: 26.00   1st Qu.: 25.00  
##  Median :2018         Median :32060   Median : 45.00   Median : 44.00  
##  Mean   :2018         Mean   :30209   Mean   : 67.08   Mean   : 67.08  
##  3rd Qu.:2020         3rd Qu.:40080   3rd Qu.: 84.00   3rd Qu.: 79.00  
##  Max.   :2022         Max.   :49340   Max.   :561.00   Max.   :670.00  
##                                                        NA's   :100     
##      births           deaths           NAME              avg_eal     
##  Min.   :  1328   Min.   :  1128   Length:1000        Min.   :38.21  
##  1st Qu.:  3617   1st Qu.:  3416   Class :character   1st Qu.:65.60  
##  Median :  6166   Median :  5294   Mode  :character   Median :75.28  
##  Mean   : 12411   Mean   : 10836                      Mean   :77.28  
##  3rd Qu.: 13648   3rd Qu.: 11576                      3rd Qu.:94.11  
##  Max.   :171670   Max.   :139494                      Max.   :99.91  
##                   NA's   :100                                        
##     tercile     avg_eal_tercile   
##  Min.   :1.00   Length:1000       
##  1st Qu.:1.00   Class :character  
##  Median :2.00   Mode  :character  
##  Mean   :1.99                     
##  3rd Qu.:3.00                     
##  Max.   :3.00                     
## 

Births Deaths Entries Exits - with parent by Risk

These are for business where there is a parent number attached

## Rows: 978 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
##  archive_version_year     CBSAFP          entry             exit       
##  Min.   :2013         Min.   :10420   Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         1st Qu.:19430   1st Qu.:  4.00   1st Qu.: 20.00  
##  Median :2018         Median :31540   Median :  8.00   Median : 36.00  
##  Mean   :2018         Mean   :30192   Mean   : 13.37   Mean   : 54.31  
##  3rd Qu.:2020         3rd Qu.:40060   3rd Qu.: 16.00   3rd Qu.: 66.00  
##  Max.   :2022         Max.   :49340   Max.   :111.00   Max.   :594.00  
##                                                        NA's   :97      
##      births            deaths           NAME              avg_eal     
##  Min.   :   12.0   Min.   :  1128   Length:978         Min.   :38.21  
##  1st Qu.:  447.0   1st Qu.:  3428   Class :character   1st Qu.:65.97  
##  Median :  797.5   Median :  5354   Mode  :character   Median :75.17  
##  Mean   : 1407.4   Mean   : 10946                      Mean   :77.35  
##  3rd Qu.: 1646.2   3rd Qu.: 11691                      3rd Qu.:94.62  
##  Max.   :19335.0   Max.   :139494                      Max.   :99.91  
##                    NA's   :96                                         
##     tercile      avg_eal_tercile   
##  Min.   :1.000   Length:978        
##  1st Qu.:1.000   Class :character  
##  Median :2.000   Mode  :character  
##  Mean   :1.993                     
##  3rd Qu.:3.000                     
##  Max.   :3.000                     
## 

Births Deaths Entries Exits - standalone by Risk

These are for business where there isn’t a parent number attached

## Rows: 1000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
##  archive_version_year     CBSAFP          entry             exit       
##  Min.   :2013         Min.   :10420   Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         1st Qu.:19348   1st Qu.: 20.00   1st Qu.: 19.00  
##  Median :2018         Median :32060   Median : 35.00   Median : 35.00  
##  Mean   :2018         Mean   :30209   Mean   : 52.28   Mean   : 53.53  
##  3rd Qu.:2020         3rd Qu.:40080   3rd Qu.: 64.00   3rd Qu.: 65.00  
##  Max.   :2022         Max.   :49340   Max.   :499.00   Max.   :594.00  
##                                                        NA's   :101     
##      births           deaths           NAME              avg_eal     
##  Min.   :  1152   Min.   :  1128   Length:1000        Min.   :38.21  
##  1st Qu.:  3337   1st Qu.:  3416   Class :character   1st Qu.:65.60  
##  Median :  5682   Median :  5294   Mode  :character   Median :75.28  
##  Mean   : 11596   Mean   : 10836                      Mean   :77.28  
##  3rd Qu.: 12722   3rd Qu.: 11576                      3rd Qu.:94.11  
##  Max.   :169862   Max.   :139494                      Max.   :99.91  
##                   NA's   :100                                        
##     tercile     avg_eal_tercile   
##  Min.   :1.00   Length:1000       
##  1st Qu.:1.00   Class :character  
##  Median :2.00   Mode  :character  
##  Mean   :1.99                     
##  3rd Qu.:3.00                     
##  Max.   :3.00                     
## 

Births Deaths Entries Exits - All by Population

This segments the data by population terciles for the top 100 CBSAs

top100_cbsa <- get_acs(geography = "cbsa", variables = c(pop="B01001_001"),output = "wide") %>%
  top_n(100,popE) %>%
  mutate(pop_tercile = ntile(popE, 3)) %>%
  mutate(pop_tercile=as_factor(pop_tercile)) %>%
  mutate(pop_tercile = factor(pop_tercile, levels = 1:3, labels = c("Pop: Low", "Pop: Moderate", "Pop: High"))) %>% 
  select(pop_tercile,GEOID)
## Getting data from the 2018-2022 5-year ACS
data <- read_csv("cbsa_births_deaths_exits_entrys.csv") %>%
  mutate(CBSAFP=as.character(CBSAFP)) %>%
  mutate(avg_eal_tercile = factor(avg_eal_tercile,
                                levels = c("Low", "Moderate", "High"))) %>%
  mutate(avg_eal_tercile = fct_recode(avg_eal_tercile,
                                      "EAL: Low" = "Low",
                                      "EAL: Moderate" = "Moderate",
                                      "EAL: High" = "High")) %>%
  left_join(top100_cbsa,by=c("CBSAFP"="GEOID"))
## Rows: 1000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary(data)
##  archive_version_year    CBSAFP              entry             exit       
##  Min.   :2013         Length:1000        Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         Class :character   1st Qu.: 26.00   1st Qu.: 25.00  
##  Median :2018         Mode  :character   Median : 45.00   Median : 44.00  
##  Mean   :2018                            Mean   : 67.08   Mean   : 67.08  
##  3rd Qu.:2020                            3rd Qu.: 84.00   3rd Qu.: 79.00  
##  Max.   :2022                            Max.   :561.00   Max.   :670.00  
##                                                           NA's   :100     
##      births           deaths           NAME              avg_eal     
##  Min.   :  1328   Min.   :  1128   Length:1000        Min.   :38.21  
##  1st Qu.:  3617   1st Qu.:  3416   Class :character   1st Qu.:65.60  
##  Median :  6166   Median :  5294   Mode  :character   Median :75.28  
##  Mean   : 12411   Mean   : 10836                      Mean   :77.28  
##  3rd Qu.: 13648   3rd Qu.: 11576                      3rd Qu.:94.11  
##  Max.   :171670   Max.   :139494                      Max.   :99.91  
##                   NA's   :100                                        
##     tercile          avg_eal_tercile        pop_tercile 
##  Min.   :1.00   EAL: Low     :340    Pop: Low     :340  
##  1st Qu.:1.00   EAL: Moderate:330    Pop: Moderate:330  
##  Median :2.00   EAL: High    :330    Pop: High    :330  
##  Mean   :1.99                                           
##  3rd Qu.:3.00                                           
##  Max.   :3.00                                           
## 

Births Deaths - with parent by Population

This segments business with a parent number by population terciles for the top 100 CBSAs

data <- read_csv("cbsa_births_deaths_exits_entrys_parent.csv") %>%
  mutate(CBSAFP=as.character(CBSAFP)) %>%
  mutate(avg_eal_tercile = factor(avg_eal_tercile,
                                levels = c("Low", "Moderate", "High"))) %>%
  mutate(avg_eal_tercile = fct_recode(avg_eal_tercile,
                                      "EAL: Low" = "Low",
                                      "EAL: Moderate" = "Moderate",
                                      "EAL: High" = "High")) %>%
  left_join(top100_cbsa,by=c("CBSAFP"="GEOID"))
## Rows: 978 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary(data)
##  archive_version_year    CBSAFP              entry             exit       
##  Min.   :2013         Length:978         Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         Class :character   1st Qu.:  4.00   1st Qu.: 20.00  
##  Median :2018         Mode  :character   Median :  8.00   Median : 36.00  
##  Mean   :2018                            Mean   : 13.37   Mean   : 54.31  
##  3rd Qu.:2020                            3rd Qu.: 16.00   3rd Qu.: 66.00  
##  Max.   :2022                            Max.   :111.00   Max.   :594.00  
##                                                           NA's   :97      
##      births            deaths           NAME              avg_eal     
##  Min.   :   12.0   Min.   :  1128   Length:978         Min.   :38.21  
##  1st Qu.:  447.0   1st Qu.:  3428   Class :character   1st Qu.:65.97  
##  Median :  797.5   Median :  5354   Mode  :character   Median :75.17  
##  Mean   : 1407.4   Mean   : 10946                      Mean   :77.35  
##  3rd Qu.: 1646.2   3rd Qu.: 11691                      3rd Qu.:94.62  
##  Max.   :19335.0   Max.   :139494                      Max.   :99.91  
##                    NA's   :96                                         
##     tercile           avg_eal_tercile        pop_tercile 
##  Min.   :1.000   EAL: Low     :332    Pop: Low     :327  
##  1st Qu.:1.000   EAL: Moderate:321    Pop: Moderate:321  
##  Median :2.000   EAL: High    :325    Pop: High    :330  
##  Mean   :1.993                                           
##  3rd Qu.:3.000                                           
##  Max.   :3.000                                           
## 

Births Deaths - standalone by Population

This segments business without a parent number by population terciles for the top 100 CBSAs

data <- read_csv("cbsa_births_deaths_exits_entrys_standalone.csv") %>%
  mutate(CBSAFP=as.character(CBSAFP)) %>%
  mutate(avg_eal_tercile = factor(avg_eal_tercile,
                                levels = c("Low", "Moderate", "High"))) %>%
  mutate(avg_eal_tercile = fct_recode(avg_eal_tercile,
                                      "EAL: Low" = "Low",
                                      "EAL: Moderate" = "Moderate",
                                      "EAL: High" = "High")) %>%
  left_join(top100_cbsa,by=c("CBSAFP"="GEOID"))
## Rows: 1000 Columns: 10
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (2): NAME, avg_eal_tercile
## dbl (8): archive_version_year, CBSAFP, entry, exit, births, deaths, avg_eal,...
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
summary(data)
##  archive_version_year    CBSAFP              entry             exit       
##  Min.   :2013         Length:1000        Min.   :  1.00   Min.   :  1.00  
##  1st Qu.:2015         Class :character   1st Qu.: 20.00   1st Qu.: 19.00  
##  Median :2018         Mode  :character   Median : 35.00   Median : 35.00  
##  Mean   :2018                            Mean   : 52.28   Mean   : 53.53  
##  3rd Qu.:2020                            3rd Qu.: 64.00   3rd Qu.: 65.00  
##  Max.   :2022                            Max.   :499.00   Max.   :594.00  
##                                                           NA's   :101     
##      births           deaths           NAME              avg_eal     
##  Min.   :  1152   Min.   :  1128   Length:1000        Min.   :38.21  
##  1st Qu.:  3337   1st Qu.:  3416   Class :character   1st Qu.:65.60  
##  Median :  5682   Median :  5294   Mode  :character   Median :75.28  
##  Mean   : 11596   Mean   : 10836                      Mean   :77.28  
##  3rd Qu.: 12722   3rd Qu.: 11576                      3rd Qu.:94.11  
##  Max.   :169862   Max.   :139494                      Max.   :99.91  
##                   NA's   :100                                        
##     tercile          avg_eal_tercile        pop_tercile 
##  Min.   :1.00   EAL: Low     :340    Pop: Low     :340  
##  1st Qu.:1.00   EAL: Moderate:330    Pop: Moderate:330  
##  Median :2.00   EAL: High    :330    Pop: High    :330  
##  Mean   :1.99                                           
##  3rd Qu.:3.00                                           
##  Max.   :3.00                                           
## 

NAICs breakdown

This breaks down by 2-digit NAICs codes

## Rows: 780 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): avg_eal_tercile
## dbl (3): archive_version_year, naics_2, rows
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 778 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): avg_eal_tercile
## dbl (3): archive_version_year, naics_2, births
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 780 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): avg_eal_tercile
## dbl (3): archive_version_year, naics_2, deaths
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 777 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): avg_eal_tercile
## dbl (3): archive_version_year, naics_2, entries
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 776 Columns: 4
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (1): avg_eal_tercile
## dbl (3): archive_version_year, naics_2, exits
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

NAICs 4 - Critical breakdown

This breaks down by 4-digit NAICs codes and filtered for critical businesses

## 
## Attaching package: 'janitor'
## The following objects are masked from 'package:stats':
## 
##     chisq.test, fisher.test
## New names:
## Rows: 2125 Columns: 6
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (3): 2022 NAICS US Code, 2022 NAICS US Title, Critical dbl (2): Seq. No.,
## Digits lgl (1): ...6
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9383 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, rows
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9172 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, births
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9262 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, deaths
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 7837 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, entries
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 7780 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, exits
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...6`

This compares critical and non-critical NAICs This breaks down by 4-digit NAICs codes and filtered for critical businesses

## New names:
## Rows: 2125 Columns: 6
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (3): 2022 NAICS US Code, 2022 NAICS US Title, Critical dbl (2): Seq. No.,
## Digits lgl (1): ...6
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9383 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, rows
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9172 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, births
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 9262 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, deaths
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 7837 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, entries
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## Rows: 7780 Columns: 4
## ── Column specification
## ──────────────────────────────────────────────────────── Delimiter: "," chr
## (1): avg_eal_tercile dbl (3): archive_version_year, naics_4, exits
## ℹ Use `spec()` to retrieve the full column specification for this data. ℹ
## Specify the column types or set `show_col_types = FALSE` to quiet this message.
## • `` -> `...6`

Critical and Population

all <- read_csv("critical_pop_all.csv")
## Rows: 220 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): pop_tercile, avg_eal_tercile, critical
## dbl (2): archive_version_year, row_count
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
births <- read_csv("critical_pop_births.csv") %>%
  filter(archive_version_year != 2012)
## Rows: 220 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): pop_tercile, avg_eal_tercile, critical
## dbl (2): archive_version_year, births
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
entries <- read_csv("critical_pop_entries.csv")%>%
  filter(archive_version_year != 2012)
## Rows: 200 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): pop_tercile, avg_eal_tercile, critical
## dbl (2): archive_version_year, entries
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
deaths <- read_csv("critical_pop_deaths.csv")%>%
  filter(archive_version_year != 2022)
## Rows: 220 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): pop_tercile, avg_eal_tercile, critical
## dbl (2): archive_version_year, deaths
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
exits <- read_csv("critical_pop_exits.csv")%>%
  filter(archive_version_year != 2022)
## Rows: 200 Columns: 5
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (3): pop_tercile, avg_eal_tercile, critical
## dbl (2): archive_version_year, exits
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
plot1 <- all %>%
  ggplot()+
  geom_line(aes(archive_version_year,row_count,color=avg_eal_tercile))+
  facet_grid(pop_tercile~critical)+
  ggtitle("Critical by population tercile, all")
plot2 <- births %>%ggplot()+
  geom_line(aes(archive_version_year,births,color=avg_eal_tercile))+
  facet_grid(pop_tercile~critical)+
  ggtitle("NAICS by tercile, births")
plot3 <- deaths %>% ggplot()+
  geom_line(aes(archive_version_year,deaths,color=avg_eal_tercile))+
  facet_grid(pop_tercile~critical)+
  ggtitle("NAICS by tercile, deaths")
plot4 <- entries %>% ggplot()+
  geom_line(aes(archive_version_year,entries,color=avg_eal_tercile))+
  facet_grid(pop_tercile~critical)+
  ggtitle("NAICS by tercile, entries")
plot5 <- exits %>% ggplot()+
  geom_line(aes(archive_version_year,exits,color=avg_eal_tercile))+
  facet_grid(pop_tercile~critical)+
  ggtitle("NAICS by tercile, exits")
ggplotly(plot1)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot2)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot3)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot4)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))
ggplotly(plot5)  %>% layout(showlegend = TRUE, legend = list(font = list(size = 6)))