[R] as.function parameters

Rui Barradas ruipbarradas at sapo.pt
Fri May 11 19:40:40 CEST 2012


Hello,

I'm not completely sure if I understand, but maybe using environments.
If each function copy in the list has a different environment, you can set
the parameters values in that environment.
Something like


f <- as.function(alist(y=,x=tmp,y+x))

env <- list(
	e1=new.env(),
	e2=new.env()
)
fun <- list(
	f1=f,
	f2=f
)

environment(fun$f1) <- env$e1
environment(fun$f2) <- env$e2
env$e1$tmp <- 2
env$e2$tmp <- 4
fun$f1(1)
fun$f2(1)


Also, a code example would be nice, like this I'm just guessing.

Hope this helps,

Rui Barradas

jackl wrote
> 
> Thanks for the fast answer..
> 
> The problem with your "free" definition of f is, that it does not
> really fit my task.
> 
> I have to build a tree where each node contains the same function
> just with adjusted parameters. Setting the parameters in the function call
> is not really an option.
> 
> Is there another way to do so?
> 
> thanks ahead
> 


--
View this message in context: http://r.789695.n4.nabble.com/as-function-parameters-tp4620390p4627079.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list