hrecht / censusapi

R package to retrieve U.S. Census data and metadata via API
https://www.hrecht.com/censusapi/
169 stars 30 forks source link

Bug report: getCensus not pulling > 2015 vintages for components. #55

Closed CVIOG-Demography closed 5 years ago

CVIOG-Demography commented 5 years ago

Describe the bug I call the getCensus function on pep/components but it only returns through period 8 (2015) although the data is available through 2017 at least.

To Reproduce pep_com <- getCensus(name="pep/components", # This is the Estimates datafile vintage = 2017, # Vintage year is set to the variable set above vars = "PERIOD", # gathering these variables region="COUNTY", # at the geography of COUNTY regionin="state:13" # within the state of Georgia )

table(pep_com$PERIOD) 1 2 3 4 5 6 7 8 159 159 159 159 159 159 159 159

Expected behavior Should return period 1-10, which is 2017.

R session information:

Additional context I contacted the Census and they said that it must be a bug in the package.

hrecht commented 5 years ago

Hi, I'm not seeing a bug here. I get the same results with the raw API call: https://api.census.gov/data/2017/pep/components?key=[KEY]&get=PERIOD&for=COUNTY&in=state%3A13 If data for 9 and 10 should be returned, it's not an issue from censusapi since it's returning the same thing as the underlying API. Adding PERIOD_DESC to the call, it says that period 8 is 2016 to 2017.

temp <- getCensus(name="pep/components",
vintage = 2017,
vars = c("PERIOD", "PERIOD_DESC"), 
region="COUNTY", 
regionin="state:13")
hrecht commented 5 years ago

Closing because this seems to be a misreading of the returned data, but I can reopen if I'm misunderstanding.

CVIOG-Demography commented 5 years ago

Thanks. I looked at the PERIOD codes and I did confuse PERIOD 8 with (year ending in) 2015, when it is (year ending in ) 2017. So that was part of it. However, I posted this same issue over at tidyverse and Kyle looked into it and reported "As a notable aside - by setting year to 2018 you can get the most recent data now as I just pushed a fix due to a change in the API." So I do think that there was a change in the CB API. Even after his fix, I still can't pull all years unless I do it individually, whereas before I could. So it might be worth taking a second look at the API. Thanks for clarifying for me.

hrecht commented 5 years ago

2018 has been available through this package since the Census Bureau made it available; tidycensus is a different package. I'm glad you were able to find a solution.