[Rd] bug in eval

Deepayan Sarkar deepayan@stat.wisc.edu
Thu, 19 Jul 2001 15:51:28 -0500 (CDT)



Is this a bug ?


> foo <- function(a, ...)
+ {
+     tl <- substitute(list(a=a))
+ 
+     ## the foll two should give the same results
+     ## according to defaults for eval
+     
+     print(eval(tl ))
+     print(eval(tl, parent.frame()))
+ }
> 
> 
> foo1 <- function(...)
+ {
+     foo(...)
+ }
> 
> test <- function(a = 6)
+ {
+     foo1(a = a)
+ }
> 
> test(10)
$a
[1] 10

Error in eval(expr, envir, enclos) : Object "a" not found
> 
> str(eval)
function (expr, envir = parent.frame(), enclos = if (is.list(envir) || 
    is.pairlist(envir)) parent.frame())  
> 



I'm having similar problems with 

eval(expr, data, parent.frame()) # doesn't work

and

eval(expr, data) # works

where data is a data frame.

Deepayan

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-devel mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-devel-request@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._