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

Duplicate column names in us_counties() #47

Open
Joe-Wasserman opened this issue Jul 28, 2022 · 0 comments
Open

Duplicate column names in us_counties() #47

Joe-Wasserman opened this issue Jul 28, 2022 · 0 comments

Comments

@Joe-Wasserman
Copy link

The object returned by us_counties() has two columns named state_name, which causes problems for functions that require unique names. make.names(unique = TRUE) makes all of the names unique.

Reprex:

usCounties <- USAboundaries::us_counties()
dplyr::left_join(usCounties, usCounties)
#> Error in `dplyr::left_join()`:
#> ! Input columns in `x` must be unique.
#> ✖ Problem with `state_name`.
usCountiesNames <- names(usCounties) |> make.names(unique = TRUE)
usCountiesUniqueNames <- purrr::set_names(usCounties, usCountiesNames)
dplyr::left_join(usCountiesUniqueNames, usCountiesUniqueNames)
#> Joining, by = c("statefp", "countyfp", "countyns", "affgeoid", "geoid", "name",
#> "namelsad", "stusps", "state_name", "lsad", "aland", "awater", "state_name.1",
#> "state_abbr", "jurisdiction_type", "geometry")
#> Error:
#> ! All columns in a tibble must be vectors.
#> ✖ Column `geometry` is a `sfc_MULTIPOLYGON/sfc` object.
#> 
#> Note that this second error is different and can only occur because the error with non-unique column names has been resolved.

Created on 2022-07-28 by the reprex package (v2.0.1)

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

No branches or pull requests

1 participant