Skip to content
Back to formatted view

Raw Message

Message-ID: <1336758040526-4627079.post@n4.nabble.com>
Date: 2012-05-11T17:40:40Z
From: Rui Barradas
Subject: as.function parameters
In-Reply-To: <1336755899037-4627012.post@n4.nabble.com>

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.