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

bind_cols() allows duplicate column names #2248

Closed
tiernanmartin opened this issue Nov 10, 2016 · 2 comments
Closed

bind_cols() allows duplicate column names #2248

tiernanmartin opened this issue Nov 10, 2016 · 2 comments
Labels

Comments

@tiernanmartin
Copy link

@tiernanmartin tiernanmartin commented Nov 10, 2016

As @hadley noted, this is likely a bug.

df1 <- mtcars %>% select(mpg,cyl,disp) %>% slice(1:5)
df2 <- mtcars %>% select(mpg,hp,drat) %>% slice(6:10)

names(one);names(two)
## [1] "mpg"  "cyl"  "disp"
## [1] "mpg"  "hp"   "drat"

df_combined <- bind_cols(df1,df2)

df_combined
## mpg cyl disp  mpg  hp drat
## 1 21.0   6  160 18.1 105 2.76
## 2 21.0   6  160 14.3 245 3.21
## 3 22.8   4  108 24.4  62 3.69
## 4 21.4   6  258 22.8  95 3.92
## 5 18.7   8  360 19.2 123 3.92

df_combined %>% select(mpg)
## Error: found duplicated column name: mpg

Seems like a good opportunity to add a suffix argument, as seen in the dplyr::*_join() verbs.

@krlmlr
Copy link
Member

@krlmlr krlmlr commented Nov 12, 2016

Thanks. Please see #2232 for a PR.

@hadley
Copy link
Member

@hadley hadley commented Feb 27, 2017

I've dispatched to tibble::repair_names(). This will eventually be responsible for generating a message.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants