我希望使用 tidycensus 包自动化从美国的所有区块组下载人口普查数据的过程。开发人员提供了下载美国境内所有区块的说明,但是,无法使用相同的方法访问块组。
这是我当前不起作用的代码
library(tidyverse)
library(tidycensus)
census_api_key("key here")
# create lists of state and county codes
data("fips_codes")
temp <- data.frame(state = as.character(fips_codes$state_code),
county = fips_codes$county_code,
stringsAsFactors = F)
temp <- aggregate(county~state, temp, c)
state <- temp$state
coun <- temp$county
# use map2_df to loop through the files, similar to the "tract" data pull
home <- map2_df(state, coun, function(x,y) {
get_acs(geography = "block group", variables = "B25038_001", #random var
state = x,county = y)
})
Run Code Online (Sandbox Code Playgroud)
由此产生的错误是
No …Run Code Online (Sandbox Code Playgroud)