Skip to content
Prev 59291 / 398502 Next

Lexical Scoping: eval(expr,envir=)

Hi Eric,

this my novice point of view (since I'm still learning R) about what 
is happening:

First, `tmp' is not an evironment. Check:

is.environment(tmp)
[1] FALSE

If you'd like to create an environment based on tmp then a simple way 
could be:

e1 <- new.env()
for(i in seq(along=tmp)) assign(names(tmp)[[i]], tmp[[i]], envir=e1)

Then, `tmp$foo()' is defined in the enviroment of `myObject()', thus 
you could set its evironment to be "e1" using:

environment(tmp$foo) <- e1

now

eval(tmp$foo(2), envir=e1)

maybe is what you want.

Of course maybe someone more experienced than me has a better 
solution-explanation but I hope this helps.

Best,
Dimitrs

----
Dimitris Rizopoulos
Ph.D. Student
Biostatistical Centre
School of Public Health
Catholic University of Leuven

Address: Kapucijnenvoer 35, Leuven, Belgium
Tel: +32/16/396887
Fax: +32/16/337015
Web: http://www.med.kuleuven.ac.be/biostat
     http://www.student.kuleuven.ac.be/~m0390867/dimitris.htm


----- Original Message ----- 
From: "Eric Lecoutre" <lecoutre at stat.ucl.ac.be>
To: <r-help at stat.math.ethz.ch>
Sent: Thursday, November 18, 2004 12:05 PM
Subject: [R] Lexical Scoping: eval(expr,envir=)