[R] do.call and environments
Thomas Petzoldt
thpe at hhbio.wasser.tu-dresden.de
Wed Mar 10 17:05:14 CET 2004
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
More information about the R-help
mailing list