【问题标题】:Census data extraction for time series时间序列的人口普查数据提取
【发布时间】:2021-12-17 05:08:10
【问题描述】:

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

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")

【问题讨论】:

    标签: time-series census


    【解决方案1】:

    您可以使用 tidycensus 函数 get_estimates() 获取从 2010 年开始每年按县划分的人口估计值。

    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 使用无法通过 tidycensus 访问的different format。但这里有一个 API 调用,可以为您提供 2000 年至 2010 年各县的人口:

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

    ["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"],
    

    【讨论】:

    • 非常感谢。
    猜你喜欢
    • 1970-01-01
    • 2023-03-10
    • 2015-04-13
    • 1970-01-01
    • 2016-11-20
    • 2016-03-23
    • 2015-07-01
    • 2023-01-27
    • 1970-01-01
    相关资源
    最近更新 更多