In addition to Thomas 's answer to the OP question, you may have to redirect the optional argument, which is the explicit argument to the wrapper function.
In this case, instead of repeating the standard value of the wrapped function in the shell definition, you can use missing to construct the call with the missing argument.
f <- function(s = "world!") cat("Hello", s) f() # Hello world! g <- function(s = NULL) eval(substitute( f(s = sub_me), list(sub_me = if(missing(s)) quote(expr =) else s))) g() # Hello world! g("you!") # Hello you!
source share