I have a function fun_1
that utilizes substitute()
on its ...
argument, and another function fun_2
with signature fun_2(...)
that implements the pattern do.call(fun_1, dots)
. I want fun_1()
inside fun_2()
to see the ...
passed to fun_2()
. Here's an illustration of what I'm trying to do.
fun_1 <- function(...) {
substitute(list(...))[-1] %>%
sapply(deparse)
}
foo <- "X"
bar <- "Y"
fun_1(foo, bar)
# [1] "foo" "bar"
fun_2 <- function(...) {
# dots <- Filter(length, ???)
# rlang::invoke(my_fun, dots)
}
fun_2(foo, bar, NULL)
# desired output:
# [1] "foo" "bar"
I think there's enough magic in rlang
to make this work but I'm having trouble figuring out how. I'm OK with modifying fun_1
as long as
fun_1()
has access to the values offoo
andbar
- The
do.call
pattern is implemented infun_2()
EDIT: I also need fun_2(list(foo, bar, NULL))
to work