Query Error

Working in RStudio, I am using the censusapi package to access Population Estimates data. Specifically, I am trying to access data on race/ethnicity from 2010-2017 using the Vintage 2017 Population Estimates. 

Running this code:

POP_COUNTY10 <-getCensus(name = "2017/pep/charagegroups", key = Sys.getenv("CENSUS_KEY"),
vars = c("GEONAME", "RACE", "HISP", "POP", "DATE_DESC"),
region = "COUNTY:*", date = "3:10")

I get this error message: "Error: error: estimated query results exceed cell limit of 500000" 

I've tried just selecting one year or one county and I get the same error. Are there any workarounds? Is this an error with RStudio?

This code works at the national and state levels.

  • Hey Amanda!

    You need to specify which state you want. Take a look at the example below, it is from the Getting started with censusapi. After specifying that you want county level data, you need to add regionin = "state:1,2" to identify the state. In this example 1 and 2 refer to Alabama and Alaska. 


    sahie_counties <- getCensus(name = "timeseries/healthins/sahie",

       vars = c("NAME", "IPRCAT", "IPR_DESC", "PCTUI_PT"),

       region = "county:*", regionin = "state:1,2", time = 2015)

    head(sahie_counties, n=12L)