In this post I will use the census API discussed in the last post to cluster the Allegheny County census tracts using PCA and k-means.
Setup library(tidyverse) library(tidycensus) library(tigris) library(sf) library(broom) library(ggfortify) library(viridis) library(janitor) library(scales) library(ggthemes) options(tigris_use_cache = TRUE) theme_set(theme_minimal()) census_vars <- load_variables(2010, "sf1", cache = TRUE) Census tracts are small geographic areas analogous to local neighborhoods.