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

Option to eval_select() to disallow empty selections #252

Closed
DavisVaughan opened this issue Nov 23, 2021 · 0 comments · Fixed by #282
Closed

Option to eval_select() to disallow empty selections #252

DavisVaughan opened this issue Nov 23, 2021 · 0 comments · Fixed by #282
Labels
feature a feature request or enhancement

Comments

@DavisVaughan
Copy link
Member

i.e.

library(tidyselect)
library(rlang)

df <- data.frame(x = 1)

# In some cases, I'd like this to be an error
eval_select(expr(starts_with("foo")), df)
#> named integer(0)

In tidyr, we have 3 places where we check that the result of eval_select() selects "at least 1 column", like
https://github.com/tidyverse/tidyr/pull/1241/files#diff-082bcbb672e069ebb562fb3b877b4d9457f867d89ba382224e1041ce90a89ff4R308

I like that this is already an error by default:

library(tidyselect)
library(rlang)

df <- data.frame(x = 1)

eval_select(expr(y), df)
#> Error: Can't subset columns that don't exist.
#> x Column `y` doesn't exist.

but I think it might make sense to have an ultra strict mode as well that can't ever result in an empty selection

@lionel- lionel- added the feature a feature request or enhancement label Mar 3, 2022
hadley added a commit that referenced this issue Aug 11, 2022
hadley added a commit that referenced this issue Aug 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants