I'm using tidyselection in some function, and I have to concatenate the first argument with the ellipsis as it could be a specific class that would need a specific treatment.
The normal behavior is this:
foo = function(x, ...){
xloc = eval_select(expr(c(x, ...)), data = iris)
return(xloc)
}
foo(everything())
I want to have everything()
as the default value when x
is NULL
(I cannot put it directly in the header for some reason).
Unfortunately, this syntax is not allowed:
bar = function(x, ...){
if(is_null(x))
x=everything() #throws an error
xloc = eval_select(expr(c(x, ...)), data = iris)
return(xloc)
}
bar(NULL)
# Error: `everything()` must be used within a *selecting* function.
# i See <https://tidyselect.r-lib.org/reference/faq-selection-context.html>.
I tried to wrap everything()
with all "mystic" functions I know: parse
, deparse
, call
, substitute
, quo
, sym
, enquo
, ensym
, ... Nothing worked (you can see here that I don't master these very well).
With what expression can I replace my x=everything()
line in my second code chunk for this function to work?
Versions:
- tidyselect version 1.0.0
- rlang version 0.4.5
- dplyr version 0.8.5