r-lib / tidyselect

A backend for functions taking tidyverse selections
https://tidyselect.r-lib.org
Other
126 stars 39 forks source link

eval_pull() #189

Open hadley opened 4 years ago

hadley commented 4 years ago

Equivalent of vars_pull() with new interface; works like eval_select() but must select exactly one columns. (And negative values count backwards from RHS)

lionel- commented 2 years ago

It probably should be stricter than vars_pull() (see #251), which entails some design work and probably a dedicated interpreter as in eval_select().

hadley commented 2 years ago

I'd be tempted to say that eval_pull() should be exactly eval_select() with the added restriction that it must return a single column. That would allow syntax that's not that useful, but a single tidyselect syntax would be easier to explain and to implement.

OTOH the different meanings of df |> select(-1) and df |> pull(-1) is going to make this at least a little tricky.

lionel- commented 2 years ago

Random thought, it seems like it might be useful for interactive usage to allow helpers like starts_with() and matches() or predicate functions in pull(). This would always select the first matching element and throw an error if none.