Attempting to use tidycensus package to download data.
As I read it, tidycensus supports blocks for 2000. Tract works, block group works, blocks fail
library(tidycensus)
library(tidyverse)
library(viridis)
library(ggplot2)
library(dplyr)
#------Get Decennial Census Data
ut2000tract <- get_decennial(geography = "tract", variables = "P001001",
year = 2000, sumfile = "sf1", key = mykey, state = "49", county = "035",
geometry = FALSE)
ut2000BG <- get_decennial(geography = "block group", variables =
"P001001", year = 2000, sumfile = "sf1",
key = mykey, state = "49", county = "035", geometry = FALSE)
ut2000block <- get_decennial(geography = "block", variables = "P001001",
year = 2000, sumfile = "sf1", key = mykey, state = "49", county = "035",
geometry = FALSE)
Generating the following error:
1 "Checking SF3 API for data..." 1 "Client error Bad Request Client error: (400) Bad Request" Error in stri_replace_first_regex(string, pattern, fix_replacement(replacement), : argument
str
should be a character vector (or an object coercible to) Error in gather.default(., key = variable, value = value, -GEOID, -NAME) :
object 'NAME' not found
I know block should be a valid geometry; I just want a count of population/block, which is in the Census 2000 SF1 file. Not sure why tidycensus is not working. Pulling data for 2010 seems to work. But not 2000.
totalcensus doesn't cover Census 2000
I'm the author of tidycensus; I answered this on the GitHub issues page (https://github.com/walkerke/tidycensus/issues/51) but I'll cross-post here.
This is due to a limitation of the Census API; block data for 2000 are only available by Census tract within counties in the API, and I don't have functionality in the package to handle this at the moment. I've added a new error message in the package to explain this. My recommended alternatives:
map_df()
to iterate through these IDs and get the output you need.