{"action":"created","issue":{"url":"https://api.github.com/repos/tidyverse/tidyselect/issues/76","repository_url":"https://api.github.com/repos/tidyverse/tidyselect","labels_url":"https://api.github.com/repos/tidyverse/tidyselect/issues/76/labels{/name}","comments_url":"https://api.github.com/repos/tidyverse/tidyselect/issues/76/comments","events_url":"https://api.github.com/repos/tidyverse/tidyselect/issues/76/events","html_url":"https://github.com/tidyverse/tidyselect/issues/76","id":363072796,"node_id":"MDU6SXNzdWUzNjMwNzI3OTY=","number":76,"title":"dplyr::select() returns a wrong column, should probably throw a \"no such column/value\" style exception","user":{"login":"move[bot]","id":33596368,"node_id":"MDM6Qm90MzM1OTYzNjg=","avatar_url":"https://avatars1.githubusercontent.com/in/6673?v=4","gravatar_id":"","url":"https://api.github.com/users/move%5Bbot%5D","html_url":"https://github.com/apps/move","followers_url":"https://api.github.com/users/move%5Bbot%5D/followers","following_url":"https://api.github.com/users/move%5Bbot%5D/following{/other_user}","gists_url":"https://api.github.com/users/move%5Bbot%5D/gists{/gist_id}","starred_url":"https://api.github.com/users/move%5Bbot%5D/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/move%5Bbot%5D/subscriptions","organizations_url":"https://api.github.com/users/move%5Bbot%5D/orgs","repos_url":"https://api.github.com/users/move%5Bbot%5D/repos","events_url":"https://api.github.com/users/move%5Bbot%5D/events{/privacy}","received_events_url":"https://api.github.com/users/move%5Bbot%5D/received_events","type":"Bot","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-09-24T09:35:53Z","updated_at":"2018-09-24T15:53:23Z","closed_at":null,"author_association":"NONE","body":"*@JohnMount commented on Sep 23, 2018, 2:35 PM UTC:*\n\n`dplyr::select()` returns a wrong column, should probably throw a \"no such column/value\" style exception.\n\n```r\nlibrary(\"dplyr\")\npackageVersion(\"dplyr\")\n\n    ## [1] '0.7.6'\n\npackageVersion(\"rlang\")\n\n    ## [1] '0.2.2'\n\npackageVersion(\"tidyselect\")\n\n    ## [1] '0.2.4'\n\ny <- \"x\"\n\ndxy <- data.frame(x = 1, y = 2)\ndx <- data.frame(x = 1) \n\n# returns column x (correct)\ndx %>%\n select(y)\n\n    ##   x\n    ## 1 1\n\n# returns column y (incorrect)\ndxy %>%\n select(y)\n\n    ##   y\n    ## 1 2\n```\n\n*This issue was moved by [romainfrancois](https://github.com/romainfrancois) from [tidyverse/dplyr#3851](https://github.com/tidyverse/dplyr/issues/3851).*"},"comment":{"url":"https://api.github.com/repos/tidyverse/tidyselect/issues/comments/424025773","html_url":"https://github.com/tidyverse/tidyselect/issues/76#issuecomment-424025773","issue_url":"https://api.github.com/repos/tidyverse/tidyselect/issues/76","id":424025773,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNDAyNTc3Mw==","user":{"login":"krlmlr","id":1741643,"node_id":"MDQ6VXNlcjE3NDE2NDM=","avatar_url":"https://avatars0.githubusercontent.com/u/1741643?v=4","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"created_at":"2018-09-24T15:53:23Z","updated_at":"2018-09-24T15:53:23Z","author_association":"MEMBER","body":"This was previously discussed in #49, with the resolution to keep the behavior. But that issue didn't include the example here:\r\n\r\n``` r\r\nlibrary(tidyselect)\r\n\r\n# Dangerous: two way to interpret\r\nx <- \"y\"\r\nvars_select(\"x\", x)\r\n#>   x \r\n#> \"x\"\r\nvars_select(\"x\", x:y)\r\n#> Error in is_character(x, encoding = encoding, n = 1L): object 'y' not found\r\nvars_select(\"x\", -x)\r\n#> named character(0)\r\nvars_select(\"y\", x)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", x:y)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", -x)\r\n#> named character(0)\r\n\r\n\r\n# Safe\r\nvars_select(\"x\", !!x)\r\n#> Error: Unknown column `y` \r\n#> Backtrace:\r\n#>  ─tryCatch(...)\r\n#>  ─vars_select(\"x\", !!x)\r\n#>  ─vars_select_eval(.vars, quos) /home/kirill/git/R/tidyselect/R/vars-select.R:118:2\r\n#>  ─map_if(ind_list, is_character, match_strings, names = TRUE) /home/kirill/git/R/tidyselect/R/vars-select.R:236:2\r\n#>  ─map(.x[sel], .f, ...) /tmp/RtmpqZVXSG/R.INSTALL62801d434702/purrr/R/map.R:112:2\r\n#>  ─.f(.x[[i]], ...) /tmp/RtmpqZVXSG/R.INSTALL62801d434702/purrr/R/map.R:104:2\r\n#>  ─bad_unknown_vars(vars, unknown) /home/kirill/git/R/tidyselect/R/vars-select.R:272:4\r\nvars_select(\"x\", (!!x):y)\r\n#> Error: Unknown column `y` \r\n#> Backtrace:\r\n#>  ─tryCatch(...)\r\n#>  ─\"y\":y\r\n#>  ─match_strings(x) /home/kirill/git/R/tidyselect/R/vars-select.R:243:4\r\n#>  ─bad_unknown_vars(vars, unknown) /home/kirill/git/R/tidyselect/R/vars-select.R:272:4\r\nvars_select(\"x\", -!!x)\r\n#> Error: Unknown column `y` \r\n#> Backtrace:\r\n#>  ─tryCatch(...)\r\n#>  ─-\"y\"\r\n#>  ─match_strings(x) /home/kirill/git/R/tidyselect/R/vars-select.R:257:4\r\n#>  ─bad_unknown_vars(vars, unknown) /home/kirill/git/R/tidyselect/R/vars-select.R:272:4\r\nvars_select(\"y\", !!x)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", (!!x):y)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", -!!x)\r\n#> named character(0)\r\n\r\n# Correct (but why is the error message misleading?)\r\nx <- rlang::sym(\"y\")\r\nvars_select(\"x\", !!x)\r\n#> Error in .f(.x[[i]], ...): object 'y' not found\r\nvars_select(\"x\", (!!x):y)\r\n#> Error in is_character(x, encoding = encoding, n = 1L): object 'y' not found\r\nvars_select(\"x\", -!!x)\r\n#> Error in is_character(x): object 'y' not found\r\nvars_select(\"y\", !!x)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", (!!x):y)\r\n#>   y \r\n#> \"y\"\r\nvars_select(\"y\", -!!x)\r\n#> named character(0)\r\n```\r\n\r\n<sup>Created on 2018-09-24 by the [reprex package](https://reprex.tidyverse.org) (v0.2.1.9000)</sup>\r\n\r\nFor now the easiest remedy might be to give an appropriate warning in the documentation, and refer to `select(!!x)`, `select(one_of())` or `select_at(vars())` for programming."}}
{"actor":{"display_login":"krlmlr"}}