-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pad fips with 0's for geocode()
#47
Comments
@atungate thanks for this, I agree this would be a good enhancement. I would just want to make sure that it's done in a way where it doesn't interfere with other columns of the same name (ie. "census_block" etc.) that might already exist in an input dataset (ie. not coming from the geocoding service results). Also, as you note having the solution in base R so that we don't have to add a dependency would be good. In line 294 of geo.R there is a call to the |
@jessecambon, sounds good and thanks for the head-start! I will take a look at things and submit a PR in the next week or two--then you can decide from there! |
@atungate I've got a fix for this in the master branch now if you want to test it out. The library(tidygeocoder)
library(dplyr)
a <- sample_addresses %>% head(3) %>% geocode(addr, full_results = TRUE, return_type = 'geographies')
View(a) |
Hey @jessecambon, works great for me! Thank you! I took a crack at fixing it upstream but couldn't figure it out. I was going to come back to it and use |
Fantastic package! One thing for you to consider is to pad the fips from
geocode(..., method = 'census', full_results = TRUE, return_type = "geographies")
with0
's on the left to be consistent with the number of digits expected (outlined by the census: https://www.census.gov/programs-surveys/geography/guidance/geo-identifiers.html#par_textimage_8). Of course, you'll also have to force those columns to be character because of the leading zeros. For example, changing this:To this:
If it would help I can submit a PR, I just need to dig into the code more to figure out if you can retain the 0's upstream or if you'll need to do it similar to how I did it (but avoiding the
stringr
import).The text was updated successfully, but these errors were encountered: