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: unknown predicate variable: 'time' in SAIPE API call #72

Closed aniruhil closed 3 years ago

aniruhil commented 3 years ago

Describe the bug Since the 2019 data are out I tried to access the 2019 SAIPE estimates.

To Reproduce `library(censusapi)

saipe <- getCensus( name = "timeseries/poverty/saipe", vars = c("NAME", "SAEPOVRT0_17_PT", "SAEPOVRTALL_PT"), region = "state:*", time = 2019) `

Expected behavior 2019 data should have rolled in. Instead the following error is thrown ...

[1] "https://api.census.gov/data/timeseries/poverty/saipe?key=blahblahblahf&get=NAME%2CSAEPOVRT0_17_PT%2CSAEPOVRTALL_PT&for=state%3A%2A&time=2019" Error in apiCheck(req) : The Census Bureau returned the following error message: error: unknown predicate variable: 'time' Your API call was: https://api.census.gov/data/timeseries/poverty/saipe?key=blahblahblah&get=NAME%2CSAEPOVRT0_17_PT%2CSAEPOVRTALL_PT&for=state%3A%2A&time=2019

R session information:

Additional context Here is my sessionInfo(), in case it helps

`R version 4.0.3 (2020-10-10) Platform: x86_64-apple-darwin17.0 (64-bit) Running under: macOS Catalina 10.15.7 Matrix products: default BLAS: /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib locale: [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] censusapi_0.7.1 loaded via a namespace (and not attached): [1] httr_1.4.2 compiler_4.0.3 R6_2.5.0 tools_4.0.3 curl_4.3 [6] yaml_2.2.1 `
hrecht commented 3 years ago

Hi, I've checked this out and it looks like the Census Bureau changed the predicate named "time" to "YEAR" with this update. Extremely frustrating! This of course breaks old code. If you change time to YEAR in your call it should work now. If you'd like to alert the Census developers please email cedsci.feedback@census.gov. Unfortunately this is an issue on their end, the R package is working as intended.

aniruhil commented 3 years ago

@hrecht will do, and thanks for the swift debugging. Happy holidays!

aniruhil commented 3 years ago

In case anyone comes wandering, this works for multiple years ....

getCensus(
  name = "timeseries/poverty/saipe",
  vars = c("NAME", "SAEPOVRT0_17_PT", "SAEPOVRTALL_PT"),
  region = "county:*",
  regionin = "state:39",
  YEAR = "2006:2019"
  ) 

but this no longer works ...

getCensus(
  name = "timeseries/poverty/saipe",
  vars = c("NAME", "SAEPOVRT0_17_PT", "SAEPOVRTALL_PT"),
  region = "county:*",
  regionin = "state:39",
  YEAR = "from 2006 to 2019"
  )

Interestingly enough the switch from time to YEAR has not plagued SAHIE data pulls.

Thanks again for a very, very useful package, @hrecht

hrecht commented 3 years ago

Thank you for flagging this @aniruhil, very frustrating! I haven't gotten any notices of these changes from the Census Bureau. Have you been in touch with them already at all? I'll make sure to update the SAHIE examples.

aniruhil commented 3 years ago

Yes, three months ago I filed a breaking change report and Logan Powell was aware of a report being having been filed.

hrecht commented 3 years ago

Thank you! Ugh. I've raised it in the Census slack channel as well.

barne415 commented 3 years ago

Good morning, just wanted to let you know that SAIPE School Districts and SAIPE State and County will be released later today with the added variable. There is no release for SAHIE right now.

hrecht commented 3 years ago

@barne415 what does this mean? What added variable? Do you work for the Census Bureau?

If so, if this is your warning of a breaking change, this is not the appropriate venue. A vague comment on a closed unrelated github issue to one user is not sufficient. Please postpone any breaking changes and send a detailed email with instructions to all users and post an announcement on the API website. This is unacceptable. cc @loganpowell

If I am misunderstanding your message please do elaborate.

barne415 commented 3 years ago

Hi @hrecht, this is not a breaking change, but a correction. Apologies for responding on your page. I will address this further in Slack.

loganpowell commented 3 years ago

@barne415 are we adding a new variable to time or is the new variable we're talking about the YEAR or something else entirely?

barne415 commented 3 years ago

@loganpowell 'time' is being added to the SAIPE API. Once this is done, users will be able to access both 'time' and 'YEAR.' But it's only happening right now for SAIPE. No release for SAHIE at the moment to fix the breaking change.

loganpowell commented 3 years ago

Ah, good to know. Thanks @barne415