library(tidycensus) library(tidyverse) library(sf) library(tmap)
raw_data<-get_acs( geography = “tract”, variables = “B25077_001”, state = “CA”, county = “Santa Clara”, year = 2021, geometry = TRUE )
map_data<-raw_data%>% mutate(estimate=as.numeric(estimate))%>% filter(!is.na(estimate),estimate>0)
map_equal<-tm_shape(map_data)+ tm_polygons(“estimate”, style=“equal”, n=5, palette=“viridis”, border.col=“grey”, lwd = 0.5, title=“Equal Interval”)+ tm_layout(frame = TRUE, frame.lwd = 2, legend.outside=TRUE)
map_quantile<-tm_shape(map_data)+ tm_polygons(“estimate”, style=“quantile”, n=5, palette=“viridis”, border.col=“grey”, lwd = 0.5, title=“Quantiles”)+ tm_layout(frame = TRUE, frame.lwd = 2, legend.outside=TRUE)
map_jenks<-tm_shape(map_data)+ tm_polygons(“estimate”, style=“jenks”, n=5, palette=“viridis”, border.col=“grey”, lwd = 0.5, title=“Natural Breaks”)+ tm_layout(frame = TRUE, frame.lwd = 2, legend.outside=TRUE)
tmap_arrange(map_equal,map_quantile,map_jenks,ncol = 3)