Skip to content
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

Fixed bug when GEOIDs are ordered differently in result chunks. #165

Merged
merged 1 commit into from
Jun 12, 2019

Conversation

weihuangwong
Copy link
Contributor

When a large number of variables (>24) are passed into get_acs, results sometimes (perhaps rarely) contain errors (perhaps many). This is because get_acs divides the variables into two or more requests, and then binds the returned results together into a dataframe, but GEOIDs may be ordered differently for each set of returned results. For example:

library(tidycensus)

variables <- c("B01001_003", "B01001_004", "B01001_005", "B01001_006", "B01001_007", 
"B01001_008", "B01001_009", "B01001_010", "B01001_011", "B01001_012", 
"B01001_013", "B01001_014", "B01001_015", "B01001_016", "B01001_017", 
"B01001_018", "B01001_019", "B01001_020", "B01001_021", "B01001_022", 
"B01001_023", "B01001_024", "B01001_025", "B01001_026", "B25002_002",
"B03003_003")

test1 <- get_acs(geography = "tract", year = 2017, variables = "B03003_003", 
                 output = "wide", state = 36, geometry = F, key = api_key)

test2 <- get_acs(geography = "tract", year = 2017, variables = variables,
                 output = "wide", state = 36, geometry = F, key = api_key)

identical(test1$B03003_003E[test1$GEOID == "36047037500"], 
          test2$B03003_003E[test2$GEOID == "36047037500"]) # FALSE

The proposed fix uses full_join on GEOID rather than bind_cols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants