Skip to content

Instantly share code, notes, and snippets.

@jhollist
Created June 1, 2017 21:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhollist/d72a93b48622dd1890e5aca8274a5f82 to your computer and use it in GitHub Desktop.
Save jhollist/d72a93b48622dd1890e5aca8274a5f82 to your computer and use it in GitHub Desktop.
library(tidycensus)
ri <- get_decennial(geography = "state", state = "RI",variables = "P001001",
key = api_key,
year = 2000)
#Returning this error...
#Using FIPS code '44' for state 'RI'
#Using FIPS code '44' for state 'RI'
#Error : lexical error: invalid char in json text.
# error: unknown/unsupported geog
# (right here) ------^
#
#Error: is.character(x) is not TRUE
@walkerke
Copy link

walkerke commented Jun 2, 2017

I don't have that direct functionality exposed at the moment. What I recommend:

library(tidycensus)
library(tidyverse)

census_api_key("your key here")

ri <- get_decennial(geography = "state", variables = "P001001", year = 2000) %>%
  filter(NAME == "Rhode Island")

My philosophy in the package design has not been to fully expose the API, but rather to help users get enough of what they need and then do the rest within the tidyverse. If this functionality would be useful, however, I'll consider putting it on the roadmap. You can also look at @hrecht's censusapi package, which fully exposes the API: https://github.com/hrecht/censusapi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment