[R] do.call and env

Thomas Petzoldt thpe at hhbio.wasser.tu-dresden.de
Wed Mar 10 18:27:25 CET 2004


Erin Hodgess wrote:

> Hi Thomas!
> 
> Try something like this:
> 
> fx <- function(y) print(x*y)
> 
> f <- function(fun,x) {
> assign("x",x,env=.GlobalEnv)
> fxx <- function() {
> do.call(fun,list(y=3))
> }
> fxx()
> }
> 
> f("fx",13)
> 
> [1] 39
> 
> 
> Hope this helps!

Thank you it works, but sorry, this is not what I want, as it assigns 
"x" to the global environment.

Thomas




More information about the R-help mailing list