【问题标题】:Using censusapi to make choropleth map of poverty rates使用 censusapi 制作贫困率等值线图
【发布时间】: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")

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    贫困表中的“B17020_001E”是指总人口。 因此,您实际上是在将总人口除以总人口,这就是为什么每个区域都得到 100% 的结果。

    “B17020_002E”是指“过去12个月收入低于贫困线的总人口”。其他列涉及按年龄组划分的贫困情况。

    所以要么使用,

    poverty &lt;- c(poverty = "B17020_002E", population = "B01003_001E")

    poverty &lt;- c(poverty = "B17020_002E", population = "B17020_001E")

    由于“B01003_001E”和“B17020_001E”都是指总人口,因此这两行将给出相同的数据

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-07
    • 2016-07-29
    • 1970-01-01
    • 2018-10-12
    • 2012-03-08
    • 2020-09-13
    相关资源
    最近更新 更多