var2022 <- load_variables(2022,"acs1/subject")

Age Population Brackets in California

age22 <- c(age85plus="S0101_C01_019", age80_84="S0101_C01_018",age75_79="S0101_C01_017",age70_74="S0101_C01_016",
            age65_69="S0101_C01_015",age60_64="S0101_C01_014",age55_59="S0101_C01_013",age50_54="S0101_C01_012",
            age45_49="S0101_C01_011",age40_44="S0101_C01_010",age35_39="S0101_C01_009",age30_34="S0101_C01_008",
            age25_29="S0101_C01_007",age20_24="S0101_C01_006",age15_19="S0101_C01_005",age10_14="S0101_C01_004",
            age5_9="S0101_C01_003",newborn_4="S0101_C01_002")
        

county2022 <- get_acs(geography = "county", variables = age22, summary_var = "S0101_C01_001",
                      year = 2022, state = "CA") %>% 
                         mutate(percent=round(100*(estimate/summary_est), digits=0)) %>%
                         arrange(as.numeric(GEOID)) 
## Getting data from the 2018-2022 5-year ACS
## Using the ACS Subject Tables
oc2022 <- county2022 %>% filter(GEOID=="06059")   

oc2022 %>% select(variable,estimate,percent) %>%
 gt() %>%   gt_color_rows(percent)    %>%  gt_theme_nytimes() %>%  
    tab_header(
    title = md("Age Population Brackets in Orange County, CA "),
    subtitle = md("by 2022 ACS Census "))  
## Warning: Domain not specified, defaulting to observed range within each
## specified column.
Age Population Brackets in Orange County, CA
by 2022 ACS Census
variable estimate percent
newborn_4 174484 5
age5_9 178182 6
age10_14 203883 6
age15_19 210803 7
age20_24 210198 7
age25_29 229756 7
age30_34 221487 7
age35_39 210163 7
age40_44 203571 6
age45_49 212412 7
age50_54 221690 7
age55_59 216048 7
age60_64 194191 6
age65_69 152776 5
age70_74 125722 4
age75_79 84613 3
age80_84 57336 2
age85plus 67912 2

Male_Age Population Brackets in California

age22male <- c(age85plus="S0101_C03_019", age80_84="S0101_C03_018",age75_79="S0101_C03_017",age70_74="S0101_C03_016",
            age65_69="S0101_C03_015",age60_64="S0101_C03_014",age55_59="S0101_C03_013",age50_54="S0101_C03_012",
            age45_49="S0101_C03_011",age40_44="S0101_C03_010",age35_39="S0101_C03_009",age30_34="S0101_C03_008",
            age25_29="S0101_C03_007",age20_24="S0101_C03_006",age15_19="S0101_C03_005",age10_14="S0101_C03_004",
            age5_9="S0101_C03_003",newborn_4="S0101_C03_002")
        

county2022 <- get_acs(geography = "county", variables = age22male, summary_var = "S0101_C03_001",
                      year = 2022, state = "CA") %>% 
                         mutate(percent=round(100*(estimate/summary_est), digits=0)) %>%
                         arrange(as.numeric(GEOID)) 
## Getting data from the 2018-2022 5-year ACS
## Using the ACS Subject Tables
oc2022male <- county2022 %>% filter(GEOID=="06059")   

oc2022male %>% select(variable,estimate,percent) %>%
 gt() %>%   gt_color_rows(percent)    %>%  gt_theme_nytimes() %>%  
    tab_header(
    title = md("Male Populations by Age Brackets in Orange County, CA "),
    subtitle = md("by 2022 ACS Census "))  
## Warning: Domain not specified, defaulting to observed range within each
## specified column.
Male Populations by Age Brackets in Orange County, CA
by 2022 ACS Census
variable estimate percent
newborn_4 89532 6
age5_9 91030 6
age10_14 104772 7
age15_19 107020 7
age20_24 106390 7
age25_29 118146 7
age30_34 113974 7
age35_39 108158 7
age40_44 100609 6
age45_49 105149 7
age50_54 110897 7
age55_59 108261 7
age60_64 96016 6
age65_69 72351 5
age70_74 58103 4
age75_79 37722 2
age80_84 24415 2
age85plus 25468 2

Female_Age Population Brackets in California

age22female <- c(age85plus="S0101_C05_019",age80_84="S0101_C05_018",age75_79="S0101_C05_017",age70_74="S0101_C05_016",
            age65_69="S0101_C05_015",age60_64="S0101_C05_014",age55_59="S0101_C05_013",age50_54="S0101_C05_012",
            age45_49="S0101_C05_011",age40_44="S0101_C05_010",age35_39="S0101_C05_009",age30_34="S0101_C05_008",
            age25_29="S0101_C05_007",age20_24="S0101_C05_006",age15_19="S0101_C05_005",age10_14="S0101_C05_004",
            age5_9="S0101_C05_003",newborn_4="S0101_C05_002")
        

county2022 <- get_acs(geography = "county", variables = age22female, summary_var = "S0101_C03_001",
                      year = 2022, state = "CA") %>% 
                         mutate(percent=round(100*(estimate/summary_est), digits=0)) %>%
                         arrange(as.numeric(GEOID)) 
## Getting data from the 2018-2022 5-year ACS
## Using the ACS Subject Tables
oc2022female <- county2022 %>% filter(GEOID=="06059")   

oc2022gender <- select(oc2022male,c(variable, estimate))
oc2022gender$female <- oc2022female$estimate
oc2022gender$male <- oc2022gender$estimate
oc2022gender$difference <- oc2022gender$male - oc2022gender$female
#---------
oc2022gender %>% select(variable,male,female,difference) %>%
 gt() %>%   gt_color_rows(difference)    %>%  gt_theme_nytimes() %>%  
    tab_header(
    title = md("Age Population by Gender in Orange County, CA "),
    subtitle = md("by 2022 ACS Census "))  
## Warning: Domain not specified, defaulting to observed range within each
## specified column.
Age Population by Gender in Orange County, CA
by 2022 ACS Census
variable male female difference
newborn_4 89532 84952 4580
age5_9 91030 87152 3878
age10_14 104772 99111 5661
age15_19 107020 103783 3237
age20_24 106390 103808 2582
age25_29 118146 111610 6536
age30_34 113974 107513 6461
age35_39 108158 102005 6153
age40_44 100609 102962 -2353
age45_49 105149 107263 -2114
age50_54 110897 110793 104
age55_59 108261 107787 474
age60_64 96016 98175 -2159
age65_69 72351 80425 -8074
age70_74 58103 67619 -9516
age75_79 37722 46891 -9169
age80_84 24415 32921 -8506
age85plus 25468 42444 -16976