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 for eval_select(allow_positional = FALSE) #363

Open
DavisVaughan opened this issue Oct 24, 2024 · 0 comments
Open

Option for eval_select(allow_positional = FALSE) #363

DavisVaughan opened this issue Oct 24, 2024 · 0 comments
Labels
feature a feature request or enhancement

Comments

@DavisVaughan
Copy link
Member

It would be nice if we had a way to disallow positional tidyselection entirely in some cases.

For example, in tidyr here tidyverse/tidyr#1541 (comment), we remove columns generated from names_from and values_from before evaluating the id_cols tidyselection to prevent the user from selecting an ID column that collides with the pivot columns. This works quite well unless you use positions in id_cols, in which case the positions you supply don't align with the data frame it is actually evaluated on.

We don't think id_cols is a great place to be providing positions anyways, so we'd like to completely turn off the ability to use positional selection here.

We think allow_positional = FALSE would affect a few places:

  • all_of() and any_of() technically allow positional inputs, so we'd need a peek_positional() helper like we have for peek_vars() to dynamically determine if we should disallow them there
  • last_col() works by position and has the potential to be quite confusing if used as an id_cols, so it should probably be completely disallowed. It would also need peek_positional().
  • In walk_data_tree() we'd check for a literal that is a numeric value and error when allow_positional = FALSE. Hopefully that catches all cases that aren't selection helpers, because everything recurses through here. Even 1:5, which does eval_colon() and recurses through walk_data_tree() with the LHS and RHS.
@DavisVaughan DavisVaughan added the feature a feature request or enhancement label Oct 24, 2024
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

No branches or pull requests

1 participant