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_rows unexpectedly renames columns #7013

Closed
lboller-pwbm opened this issue Apr 10, 2024 · 1 comment
Closed

bind_rows unexpectedly renames columns #7013

lboller-pwbm opened this issue Apr 10, 2024 · 1 comment

Comments

@lboller-pwbm
Copy link

If column names have "default" column names from dplyr, bind_rows will sometimes change the number of the column name unexpectedly. Reprex below. I would expect that this line would not rename the columns but return the tibble unchanged.

dplyr::bind_rows(list(tibble::tibble(...2 = 1, ...3 = 2)))
#> New names:
#> • `...2` -> `...1`
#> • `...3` -> `...2`
#> # A tibble: 1 × 2
#>    ...1  ...2
#>   <dbl> <dbl>
#> 1     1     2

Created on 2024-04-10 with reprex v2.1.0

@DavisVaughan
Copy link
Member

In vctrs::vec_as_names() we mention

Pre-existing suffixes of the form ...j are always stripped, prior to making names unique, i.e. reconstructing the suffixes. If this interacts poorly with your names, you should take control of name repair.

I don't think we need to re-mention this here, as it is sufficiently niche.

The main idea is that behavior with these ...j names is not something you should really rely on. Those names are there to make you as the user aware that something weird is happening, and it encourages you to try and handle the names explicitly using some better mechanism.

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