Hello,

I want to call a function "fx" given by name, where some "global" variables (in the environment of fx) are passed to the function. For compatibility reasons I cannot modify the parameter list of fx and I want to avoid setting variables in the global environment (e.g. via <<-)

Is there a way, how to do this?

Thomas P.

The example:

fx <- function(y) print(x*y)

f <- function(fun, xx) {
  fxx <- function() {do.call(fun, list(y=3))}
  x <- x
  fxx()
}

f("fx", 13)

## does not work, because fx does not find x

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to