【发布时间】:2020-07-19 19:15:43
【问题描述】:
我正在尝试使用 censusapi、tigris 和 ggplot2 包创建新奥尔良人口普查区的贫困等值线图。我使用 listCensusMetadata() 查找了以下表 ID,以获取我想要的数据:
B17020_001E: 估计!!总计 - 过去 12 个月内按年龄划分的贫困状况
B01003_001E: 估计!!总计 - 总人口
这些看起来是对的,但是当我调用这些表时,它们的值几乎完全相同。结果,看起来几乎每个人口普查区都有 100% 的贫困率。我如何知道要使用哪些表以及我使用的表是否正确?
这是我的代码。
#Must sign up for a Census key here in order to access the data: https://api.census.gov/data/key_signup.html
census_api_key("INSERT KEY HERE")
options(tigris_class = "sf")
poverty <- c(poverty = "B17020_001E",
population = "B01003_001E")
nola <- get_acs(geography="tract", year=2016, variables= poverty, county = "Orleans", state="LA", geometry=T)
nola_poverty = nola %>%
mutate(variable=case_when(
variable=="B17020_001" ~ "Poverty",
variable=="B01003_001" ~ "Population")) %>%
select(-moe) %>%
spread(variable, estimate) %>%
mutate(percent_poverty=round(Poverty/Population*100,2))
ggplot(nola_poverty) +
geom_sf(color="#0d394e", size = 0.5, aes(fill=percent_poverty)) +
theme_void() +
scale_fill_distiller(palette="Blues", direction=1, name="Poverty")
【问题讨论】: