I must admit I'm a little ashamed to have been using R for so long,
and still lack a sound understanding of deferred calls, eval, deparse,
substitute, and friends.

I'm attempting to make a deferred call to a function which has default
arguments in the following way:

call.foo <- function(f) {
    x <- f()
}

x <- 1:10
f <- function(x=x) { x^2 }
call.foo(f)

However, I'm getting the error:
Error in x^2 : 'x' is missing

Is there a common R idiom for calling 'formals' on the function, and
then grabbing the named default arguments from the enclosing frame?

I naively thought that since function 'f' was defined w/ a default
argument of 'x' and x is defined in the same envir as the function
itself, that the call would succeed.

-Whit

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to