1 Demographics comparison

1.1 Population by sex

# population

sm_demog %>% 
  filter(grepl("population", Description)) %>% 
  bind_rows(
    al_demog %>% filter(grepl("population", Description)) 
  ) %>% 
  filter(Description != "Total population") %>% 
  ggplot(aes(x = NAME, y = estimate, fill = Description)) + 
  geom_bar(position="stack", stat="identity") + 
  theme_few() + 
  xlab("") + 
  labs(title = "Population Estimate - by sex") + 
  theme(legend.position = "bottom")

1.2 Population by race & ethnicity

sorry about the rough category – need to think more carefully about how to represent this info – the census has a lot more fine grained data

sm_demog %>% 
  filter(grepl("B03002", variable)) %>% 
  bind_rows(
    al_demog %>% filter(grepl("B03002", variable)) 
  ) %>% 
  filter(Description != "Total population") %>% 
  ggplot(aes(x = NAME, y = estimate, fill = Description)) + 
  geom_bar(position="stack", stat="identity") + 
  theme_few() + 
  xlab("") + 
  labs(title = "Population Estimate - by race and ethnicity ") + 
  theme(legend.position = "bottom")

1.3 Mean age comparison

“The Census Bureau typically calculates the MOE at a 90% confidence level for the ACS estimates. This means that if you were to draw many samples from the population and calculate the estimate and MOE for each sample, then approximately 90% of those intervals would contain the true population value.”

sm_demog %>% 
  filter(grepl("B01002_001", variable)) %>% 
  bind_rows(
    al_demog %>% filter(grepl("B01002_001", variable)) 
  ) %>% 
  filter(Description != "Total population") %>% 
  ggplot(aes(x = NAME, y = estimate, ymin = estimate - moe, ymax = estimate + moe)) + 
  geom_pointrange() + 
  theme_few() + 
  xlab("") + 
  labs(title = "Population Estimate - age")

2 Housing resource

2.1 Ratio

bind_rows(
  sm_housing, al_housing
) %>% 
  filter(variable == "B25001_001") %>% 
  left_join(bind_rows(
  sm_demog, al_demog
) %>% filter(variable == "B01001_001") %>% 
  rename(population_estimate = estimate) %>% select(NAME, population_estimate), by = "NAME") %>% 
  mutate(
    housing_to_person_ratio = estimate / population_estimate
  ) %>% 
  select(NAME, estimate, population_estimate, housing_to_person_ratio) %>% 
  rename(`County Name` = NAME, 
         `Housing units estimate` = estimate, 
         `Population estimate` = population_estimate, 
         `Housing-to-person Ratio` = housing_to_person_ratio) %>% 
  kbl() %>%
  kable_styling()
County Name Housing units estimate Population estimate Housing-to-person Ratio
San Mateo County, California 278756 765623 0.3640904
Alameda County, California 605767 1661584 0.3645720

2.2 Occupancy

bind_rows(
  sm_housing, al_housing
) %>% 
  filter(grepl("B25002", variable)) %>% 
  filter(!grepl("001", variable)) %>% 
  ggplot(aes(x = NAME, y = estimate, fill = Description)) + 
  geom_bar(position="fill", stat="identity") + 
  theme_few() + 
  xlab("") + 
  labs(title = "Housing status - By occupancy") + 
  theme(legend.position = "bottom")

2.3 Housing type

bind_rows(
  sm_housing, al_housing
) %>% 
  filter(grepl("B25004", variable)) %>% 
  filter(!grepl("001", variable)) %>% 
  ggplot(aes(x = NAME, y = estimate, fill = Description)) + 
  geom_bar(position="fill", stat="identity") + 
  theme_few() + 
  xlab("") + 
  labs(title = "Vacancy status - By type") + 
  theme(legend.position = "bottom")

2.4 Housing structure (# of units in structure)

bind_rows(
  sm_housing, al_housing
) %>% 
  filter(grepl("B25024", variable)) %>% 
  filter(!grepl("001", variable)) %>% 
  ggplot(aes(x = NAME, y = estimate, fill = Description)) + 
  geom_bar(position="fill", stat="identity") + 
  theme_few() + 
  xlab("") + 
  labs(title = "Housing structure - By housing type") + 
  theme(legend.position = "bottom")