1

我认为非常简单的问题,但不确定正确的解决方案。对此进行了一些研究,并认为我记得在某处看到过解决方案,但不记得在哪里......无论如何,

想要获取 DP03,即 2019 年所有俄亥俄县的一年 acs 数据。但是,下面的代码仅访问俄亥俄州 88 个县中的 39 个。我怎样才能进入剩余的县?

我的猜测是,只有人口超过 60,000 的县才会提取数据。

library(tidycensus)
library(tidyverse)


acs_2019 <- load_variables(2019, dataset = "acs1/profile")

DP03 <- acs_2019 %>% 
  filter(str_detect(name, pattern = "^DP03")) %>% 
  pull(name, label)

Ohio_county <- 
  get_acs(geography = "county",
          year = 2019,
          state = "OH",
          survey = "acs1",
          variables = DP03,
          output = "wide")

这导致一个看起来像这样的表......

Ohio_county
# A tibble: 39 x 550
   GEOID NAME  `Estimate!!EMPL~ `Estimate!!EMPL~ `Estimate!!EMPL~ `Estimate!!EMPL~ `Estimate!!EMPL~
   <chr> <chr>            <dbl>            <dbl>            <dbl>            <dbl>            <dbl>
 1 39057 Gree~           138295              815           138295               NA            87465
 2 39043 Erie~            61316              516            61316               NA            38013
 3 39153 Summ~           442279             1273           442279               NA           286777
 4 39029 Colu~            83317              634            83317               NA            48375
 5 39099 Maho~           188298              687           188298               NA           113806
 6 39145 Scio~            60956              588            60956               NA            29928
 7 39003 Alle~            81560              377            81560               NA            49316
 8 39023 Clar~           108730              549           108730               NA            64874
 9 39093 Lora~           250606              896           250606               NA           150136
10 39113 Mont~           428140              954           428140               NA           267189

很确定我在某处看到了解决方案,但不记得在哪里。

任何帮助将不胜感激,因为它可以让办公室更轻松地提取人口普查数据,而不是费力地通过美国人口普查局网站。祝你好运,谢谢!

4

1 回答 1

0

我的同事已经提取了数据,但没有具体说明 DP03 数据是来自 ACS 1 年调查还是 ACS 5 年调查。事实证明,它来自 ACS 5 年调查,其中包括所有俄亥俄县,而不仅仅是那些人口超过 65,000 的县。按照上面的评论来描述如何确定这个答案。

所有县的代码都在这里

library(tidycensus)
library(tidyverse)

acs_2018 <- load_variables(2018, dataset = "acs5/profile")


DP03 <- acs_2019 %>% 
  filter(str_detect(name, pattern = "^DP03")) %>% 
  pull(name)

Ohio_county <- 
  get_acs(geography = "county",
          year = 2018,
          state = "OH",
          survey = "acs5",
          variables = DP03,
          output = "wide")
于 2020-12-03T16:55:10.880 回答