r-lib / tidyselect

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

validate_vars()? #85

Closed lionel- closed 5 years ago

lionel- commented 5 years ago

Do we need tidyselect::validate_vars(), that would take a character vector of names and throw appropriate errors if not found?

Using vars_select() for this is a bit awkward because of the need to unquote (and both !! and !!! work, which doesn't help with the awkwardness)

vars <- tidyselect::vars_select(vars, !!sel)
vars <- tidyselect::vars_select(vars, !!!sel)

validate_vars() would take the data (and require names() method? The tbl_vars() generic is in dplyr...) and a character vector:

vars <- tidyselect::validate_vars(data, sel)
hadley commented 5 years ago

Where would you use this?

lionel- commented 5 years ago

I don't remember exactly, but this had to do with tidyeval users taking inputs with ensyms() as an attempt to be strict about looking up the symbols only in the data frame. This is not the right way to be strict however, as the symbol will still be looked up inside the execution env of the user's wrapper, all the way up to the search path. I wasn't planning on implementing this now because I haven't thought about the issue for a while.

hadley commented 5 years ago

I'm in favour of closing issues if you don't remember exactly why you need them 😉

lionel- commented 5 years ago

I have transferred the issue to https://github.com/tidyverse/tidyeval/issues/34.