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

dplyr::select() returns a wrong column, should probably throw a "no such column/value" style exception #3851

Closed
JohnMount opened this issue Sep 23, 2018 · 3 comments

Comments

@JohnMount
Copy link

JohnMount commented Sep 23, 2018

dplyr::select() returns a wrong column, should probably throw a "no such column/value" style exception.

library("dplyr")
packageVersion("dplyr")


    ## [1] '0.7.6'


packageVersion("rlang")


    ## [1] '0.2.2'


packageVersion("tidyselect")


    ## [1] '0.2.4'


y <- "x"

dxy <- data.frame(x = 1, y = 2)
dx <- data.frame(x = 1) 

# returns column x (correct)
dx %>%
 select(y)


    ##   x
    ## 1 1


# returns column y (incorrect)
dxy %>%
 select(y)

    ##   y
    ## 1 2
@JohnMount JohnMount changed the title dplyr::select() returns a wrong column, when instead it should throw a "no such column/value" style exception dplyr::select() returns a wrong column, should probably throw a "no such column/value" style exception Sep 23, 2018
@romainfrancois
Copy link
Member

This is the documented behavior. Columns have priority in dxy %>% select(y) so the y column is selected. There is no y in dx so y is evaluated (to "x").

This is in essence, tidyselect semantics, I guess what you describe is [ standard evaluation semantics.

@ghost
Copy link

ghost commented Sep 24, 2018

This issue was moved by romainfrancois to tidyverse/tidyselect#76.

@ghost ghost closed this as completed Sep 24, 2018
@lock
Copy link

lock bot commented Mar 23, 2019

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators Mar 23, 2019
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants