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: CPS Basic variable names #84

Closed matiasds closed 2 years ago

matiasds commented 2 years ago

Describe the bug I'm not able to get the variable names of CPS basic monthly datasets.

To Reproduce cps_vars <- listCensusMetadata( name = "cps/basic/jan", vintage = 2022, type = "variables")

Expected behavior I expected to get the variable names of the CPS basic monthly data sets. I instead get the following error message: "Error in rbind(deparse.level, ...) : numbers of columns of arguments do not match

R session information:

Additional context Add any other context about the problem here.

hrecht commented 2 years ago

Hello, is this for the microdata APIs https://www.census.gov/data/developers/data-sets/census-microdata-api.CPS.html ? If so, they're structured pretty differently than the summary data APIs. Your best bet for the microdata would be to use tidycensus, which has functions for those endpoints, or to use IPUMS which has nicely cleaned data and an R package. Let me know if I'm misunderstanding.

hrecht commented 2 years ago

Hello @matiasds - the new developement version of censusapi, 0.8.0, should fix this. It turns out the Census Bureau was using invalid json key-value pair names in the CPS metadata, which caused this error. It's now working on my end - could you try again using the latest version? You can get that using the devtools package:

# install.packages("devtools")
devtools::install_github("hrecht/censusapi")

There's also a new work in progress vignette about accessing microdata that might be helpful - it's very much in development, open to feedback.

hrecht commented 2 years ago

I'm leaving this open pending further testing to make sure there aren't other invalid characters in the new API endpoints.

hrecht commented 2 years ago

Closing the loop, this fix is now available in the new release on CRAN.

matiasds commented 2 years ago

Thank you so much, @hrecht. And sorry for the late reply. I'm relatively new to GitHub.

hrecht commented 2 years ago

No worries! Thanks for flagging the issue.