私はtidycensusパッケージを使用して、米国のすべてのブロックグループから国勢調査データをダウンロードするプロセスを自動化する予定です。 US内のすべての領域をダウンロードするように開発者から指示がありますが、同じmethodを使用してブロックグループにアクセスすることはできません。ここ r tidycensusすべてのブロックグループをダウンロード
は、結果として得られるエラーも 動作しないNo encoding supplied: defaulting to UTF-8.
Error: parse error: premature EOF
(right here) ------^
リストに各状態内の郡を変換するための類似のアプローチである
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)
})
動作しない私の現在のコードであります
temp <- aggregate(county~state, temp, c)
state <- temp$state
coun <- temp$county
df<- map2_df(state, coun, function(x,y) {
get_acs(geography = "block group", variables = "B25038_001",
state = x,county = y)
})
Error: Result 1 is not a length 1 atomic vector
が返されます。
これをどのように完了できるか理解している人はいますか?おそらく私は関数や構文を正しく使用していない可能性がありますが、私もループはあまりよくありません。どんな助けもありがとう。
センサス2000はまだカバーしていますか? – Mox
@Moxはまだ、来月に追加されます –
これに関するアップデートはありますか? – Mox