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

select should be able to drop columns by number when duplicate names exist #94

Closed
WilDoane opened this issue Jun 6, 2019 · 2 comments · Fixed by #118
Closed

select should be able to drop columns by number when duplicate names exist #94

WilDoane opened this issue Jun 6, 2019 · 2 comments · Fixed by #118
Labels

Comments

@WilDoane
Copy link

@WilDoane WilDoane commented Jun 6, 2019

When a data.frame contains columns with the same name, select can't be used to correct the problem by dropping columns.

Even if rename and other verbs are problematic in this regard, dropping duplicate columns should (in principle) be possible.


Consider these error cases:

tibble::tribble(
  ~a, ~a, ~b,
  1, 2, 3
) %>% 
  select(-1)

or

tibble::tribble(
  ~a, ~a, ~b,
  1, 2, 3
) %>% 
  select(starts_with("a"))
@batpigandme
Copy link
Member

@batpigandme batpigandme commented Jun 6, 2019

reprex with backtrace:

suppressPackageStartupMessages(library(tidyverse))
tibble::tribble(
  ~a, ~a, ~b,
  1, 2, 3
) %>% 
  select(-1)
#> Can't bind data because some arguments have the same name
rlang::last_error()
#> <error>
#> message: Can't bind data because some arguments have the same name
#> class:   `rlang_error`
#> backtrace:
#>   1. tibble::tribble(~a, ~a, ~b, 1, 2, 3)
#>  10. dplyr::select(., -1)
#>  11. tidyselect::vars_select(sel_vars(.data), !!!enquos(...))
#>  12. tidyselect:::vars_select_eval(.vars, quos)
#>  13. rlang::child_env(data_helpers_env, !!!data)
#>  14. rlang:::env_bind_impl(env, list2(...))
#> Call `rlang::last_trace()` to see the full backtrace

Created on 2019-06-06 by the reprex package (v0.3.0)

@romainfrancois
Copy link
Collaborator

@romainfrancois romainfrancois commented Jun 7, 2019

Moving this to tidyselect.

tidyselect::vars_select(c("a", "a", "b"), -1)
#> Can't bind data because some arguments have the same name

Created on 2019-06-07 by the reprex package (v0.2.1)

@romainfrancois romainfrancois transferred this issue from tidyverse/dplyr Jun 7, 2019
@lionel- lionel- added the dsl label Sep 9, 2019
lionel- added a commit to lionel-/tidyselect that referenced this issue Sep 18, 2019
lionel- added a commit to lionel-/tidyselect that referenced this issue Sep 18, 2019
lionel- added a commit to lionel-/tidyselect that referenced this issue Sep 18, 2019
lionel- added a commit to lionel-/tidyselect that referenced this issue Sep 23, 2019
lionel- added a commit to lionel-/tidyselect that referenced this issue Oct 3, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants