【发布时间】:2020-06-12 03:46:11
【问题描述】:
我能够使用 tidycensus 和 tigris 准备一个县的人口普查区地图(显示所有人口普查区)。我在一个名为demography 的单独数据框中有一些数据,其中包含county、tract、x.foreclosure_filing 和delinquent_parcels 4 列。
如何创建仅包含 demography(仅 19 个区域)数据框中的那些区域的地图,并在地图中为这些 (19 个区域) 显示 x.foreclosure_filing 和 delinquent_parcels 的值?
人口统计数据框如下所示:
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
代码
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")
【问题讨论】:
标签: r leaflet tigris tidycensus