首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >时间序列的人口普查数据提取

时间序列的人口普查数据提取
EN

Stack Overflow用户
提问于 2021-11-02 17:07:23
回答 1查看 56关注 0票数 0

我正在尝试使用tidycensus下载AZ县的平均人口,使用以下代码。如何下载2000-2019年的时间序列期间的人口数据(对没有十年一次的人口普查或acs数据的年份进行插值)

代码语言:javascript
复制
library(tidycensus)
library(tidyverse)
soc.2010 <- get_decennial(geography = "county", state = "AZ", year = 2010, variables = (c(pop="P001001")), survey="sf1")

soc.16 <- get_acs(geography = "county", year=2016, variables = (c(pop="B01003_001")),state="AZ", survey="acs5") %>% mutate(Year = "2016")
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-11-10 15:52:21

您可以使用整洁的人口普查函数get_estimates()来获取从2010年开始的每个县的人口估计值。

代码语言:javascript
复制
library(tidycensus)
library(dplyr)

get_estimates(
  geography = "county",
  state = "AZ",
  product = "population",
  time_series = TRUE
  ) %>% 
  filter(DATE >= 3) %>% 
  mutate(year = DATE + 2007)
#> # A tibble: 300 x 6
#>    NAME                  DATE GEOID variable   value  year
#>    <chr>                <dbl> <chr> <chr>      <dbl> <dbl>
#>  1 Pima County, Arizona     3 04019 POP       981620  2010
#>  2 Pima County, Arizona     4 04019 POP       988381  2011
#>  3 Pima County, Arizona     5 04019 POP       993052  2012
#>  4 Pima County, Arizona     6 04019 POP       997127  2013
#>  5 Pima County, Arizona     7 04019 POP      1004229  2014
#>  6 Pima County, Arizona     8 04019 POP      1009103  2015
#>  7 Pima County, Arizona     9 04019 POP      1016707  2016
#>  8 Pima County, Arizona    10 04019 POP      1026391  2017
#>  9 Pima County, Arizona    11 04019 POP      1036554  2018
#> 10 Pima County, Arizona    12 04019 POP      1047279  2019
#> # ... with 290 more rows

API返回一些令人困惑的日期代码,我已将其转换为年份。有关详细信息,请参阅date code to year mapping for 2019 population estimates

在2010年前的几年中,人口普查API使用的different format不能通过整洁人口普查访问。但这里有一个API调用,它给出了2000到2010年间每个县的人口:

https://api.census.gov/data/2000/pep/int_population?get=GEONAME,POP,DATE_DESC&for=county:*&in=state:04

代码语言:javascript
复制
["Graham County, Arizona","33356","7/1/2001 population estimate","04","009"],
["Graham County, Arizona","33224","7/1/2002 population estimate","04","009"],
["Graham County, Arizona","32985","7/1/2003 population estimate","04","009"],
["Graham County, Arizona","32703","7/1/2004 population estimate","04","009"],
["Graham County, Arizona","32964","7/1/2005 population estimate","04","009"],
["Graham County, Arizona","33701","7/1/2006 population estimate","04","009"],
["Graham County, Arizona","35175","7/1/2007 population estimate","04","009"],
["Graham County, Arizona","36639","7/1/2008 population estimate","04","009"],
["Graham County, Arizona","37525","7/1/2009 population estimate","04","009"],
["Graham County, Arizona","37220","4/1/2010 Census 2010 population","04","009"],
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69814369

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档