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

No way to remove duplicate column names #4615

Closed
jzadra opened this issue Nov 15, 2019 · 4 comments
Closed

No way to remove duplicate column names #4615

jzadra opened this issue Nov 15, 2019 · 4 comments
Labels
bug selection 🧺

Comments

@jzadra
Copy link

jzadra commented Nov 15, 2019

Some joins will allow a tibble to end up with two columns with identical names. Doing any sort of tidyselect operation on the tibble results in:

Error: Can't bind data because some arguments have the same name

However, there doesn't appear to be any way to remove the duplicated column. It seems to me that using select(-matches("duplicate name")) or select(-contains("duplicated name")) ought to work since they allow catching multiples. In addition, selecting based on the index should also work. If columns 100 and 101 have the same name, I should be able to select(-101) however these all result in the same Error: Can't bind data because some arguments have the same name

@moodymudskipper

This comment has been minimized.

@jzadra
Copy link
Author

jzadra commented Nov 15, 2019

Thanks for that. My only concern about this as a long term solution would be the risk of affecting other names in the tibble unintentionally.

@moodymudskipper
Copy link

moodymudskipper commented Nov 15, 2019

test[!duplicated(names(test))] is probably the safest way to go

@hadley hadley added bug selection 🧺 labels Dec 10, 2019
@hadley
Copy link
Member

hadley commented Dec 10, 2019

We now have the tooling to handle this in the dev version of tidyselect and it should be straight forward to update dplyr.

hadley added a commit that referenced this issue Jan 8, 2020
@hadley hadley closed this as completed in 3d45972 Jan 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug selection 🧺
Projects
None yet
Development

No branches or pull requests

3 participants