From deepayan@stat.wisc.edu  Thu Jul 19 21:51:28 2001
From: deepayan@stat.wisc.edu (Deepayan Sarkar)
Date: Thu, 19 Jul 2001 15:51:28 -0500 (CDT)
Subject: [Rd] bug in eval
Message-ID: <Pine.LNX.4.21.0107191543030.20317-100000@gstat03.stat.wisc.edu>



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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] bug in eval
Deepayan Sarkar