You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several years ago, when there were FAR less Census Bureau API endpoints, I added some optional parameters to getCensus() that were convenience options for some of the economic data endpoints. The package supported the use arbitrary parameters (predicates, in Census-speak) since v0.6.0, released on CRAN in 2019, so this is both unnecessary and unwieldy. Also, catering specifically to certain endpoints in this function is not in scope of the package.
The named parameters are: c("year", "date", "period", "monthly", "category_code", "data_type_code", "naics", "pscode", "naics2012", "naics2007", "naics2002", "naics1997", "sic")
year was added to the list in v0.7.2 when some of the endpoints were swinging back and forth between using time versus year. They are now more consistent and many of the timeseries APIs use lowercase time as a required predicate. YEAR is a variable name in hundreds of the non-timeseries APIs.
The vast majority of this list are actually UPPERCASE predicates in the APIs, not lowercase.
Users will still be able to use the full functionality of the APIs with arbitrary parameters without having these as named optional parameters.
For example, use uppercase YEAR here instead of lowercase year. But really, the preferred syntax now is time, which is the endpoint's true predicate for filtering the timeseries.
# oldsaipe_schools<- getCensus(
name="timeseries/poverty/saipe/schdist",
vars= c("SD_NAME", "SAEPOV5_17V_PT", "SAEPOVRAT5_17RV_PT"),
region="school district (unified):*",
regionin="state:25",
year=2022)
# new and valid but not preferredsaipe_schools<- getCensus(
name="timeseries/poverty/saipe/schdist",
vars= c("SD_NAME", "SAEPOV5_17V_PT", "SAEPOVRAT5_17RV_PT"),
region="school district (unified):*",
regionin="state:25",
YEAR=2022)
# preferredsaipe_schools<- getCensus(
name="timeseries/poverty/saipe/schdist",
vars= c("SD_NAME", "SAEPOV5_17V_PT", "SAEPOVRAT5_17RV_PT"),
region="school district (unified):*",
regionin="state:25",
time=2022)
The text was updated successfully, but these errors were encountered:
To test the usage of these named predicates, I retrieved variable metadata for all timeseries and aggregate endpoints with listCensusMetadata(). Here's how often each are used:
Note that in almost all cases the predicates are actually uppercase, not lowercase. getCensus() coerces all but data_type_code and category_code to uppercase in the request construction. The timeseries/qwi/sa, timeseries/qwi/se, timeseries/qwi/rh endpoints use lowercase year as a predicate. (Documentation: https://www.census.gov/data/developers/data-sets/qwi.html)
This coercion to uppercase results in the following code failing because the required year predicate truly is lowercase here:
qwi<- getCensus(
name="timeseries/qwi/sa",
vars="Emp",
region="state:02",
year=2021,
quarter=1)
# Error in apiCheck(req) : # The Census Bureau returned the following error message:# error: unknown predicate variable: 'YEAR' # Your API call was: https://api.census.gov/data/timeseries/qwi/sa?key=[KEY]&get=Emp&for=state%3A02&YEAR=2021&quarter=1
Deprecating these named parameters is now also a bug fix to avoid this error.
hrecht
changed the title
Remove outdated/unnecessary arbitrary parameters from getCensus()
Remove outdated/unnecessary named parameters from getCensus() to fix bug and be in line with package ethos
Mar 26, 2024
hrecht
changed the title
Remove outdated/unnecessary named parameters from getCensus() to fix bug and be in line with package ethos
Deprecate outdated/unnecessary named parameters from getCensus() to fix bug and be in line with package ethos
Mar 26, 2024
Several years ago, when there were FAR less Census Bureau API endpoints, I added some optional parameters to
getCensus()
that were convenience options for some of the economic data endpoints. The package supported the use arbitrary parameters (predicates, in Census-speak) since v0.6.0, released on CRAN in 2019, so this is both unnecessary and unwieldy. Also, catering specifically to certain endpoints in this function is not in scope of the package.The named parameters are:
c("year", "date", "period", "monthly", "category_code", "data_type_code", "naics", "pscode", "naics2012", "naics2007", "naics2002", "naics1997", "sic")
year
was added to the list in v0.7.2 when some of the endpoints were swinging back and forth between usingtime
versusyear
. They are now more consistent and many of the timeseries APIs use lowercasetime
as a required predicate.YEAR
is a variable name in hundreds of the non-timeseries APIs.The vast majority of this list are actually UPPERCASE predicates in the APIs, not lowercase.
Users will still be able to use the full functionality of the APIs with arbitrary parameters without having these as named optional parameters.
For example, use uppercase
YEAR
here instead of lowercaseyear
. But really, the preferred syntax now istime
, which is the endpoint's true predicate for filtering the timeseries.The text was updated successfully, but these errors were encountered: