I was able to prepare census tracts map of a county (showing all census tracts) using tidycensus
and tigris
. I have some data in a separate dataframe called demography
which contains 4 columns county
,tract
, x.foreclosure_filing
, and delinquent_parcels
.
How do I create a map of only those tracts that are in the demography
(only 19 tracts) dataframe and show the value of x.foreclosure_filing
, and delinquent_parcels
for these (19) tracts in the map?
demography dataframe looks like this:
County tract X.foreclosure_filings delinquent_parcels
1 Cuyahoga 1401.00 8 13.52
2 Cuyahoga 1403.01 18 22.25
3 Cuyahoga 1403.02 18 11.96
4 Cuyahoga 1404.00 19 8.44
5 Cuyahoga 1405.00 27 10.93
6 Cuyahoga 1407.01 17 13.77
code
library(tidycensus)
library(tidyverse)
options(tigris_use_cache = TRUE)
clevelandhts <- get_acs(state = "OH", county = "Cuyahoga", geography = "tract",
variables = "B19013_001", geometry = TRUE)
View(clevelandhts)
clevelandhts %>%
ggplot(aes(fill = estimate)) +
geom_sf(color = NA) +
coord_sf(crs = 26917) +
scale_fill_viridis_c(option = "magma")