[R] substitute question

Gabor Grothendieck ggrothendieck at myway.com
Thu Mar 18 04:09:50 CET 2004



I left out the brackets in my last email but the problem
(a reappears after have been substituted out) still remains:

> z <- substitute( function(){a+1}, list(a=quote(b)) )
> z
function() {
    b + 1
}
> eval(z)
function(){a+1}



---
Date:   Wed, 17 Mar 2004 20:10:43 -0500 (EST) 
From:   Gabor Grothendieck <ggrothendieck at myway.com>
[ Add to Address Book | Block Address | Report as Spam ] 
To:   <R-help at stat.math.ethz.ch> 
Subject:   [R] substitute question 

 




Consider the following example:

# substitute a with b in the indicated function. Seems to work.
> z <- substitute( function()a+1, list(a=quote(b)) )
> z
function() b + 1

# z is an object of class call so use eval
# to turn it into an object of class expression; however,
# when z is evaluated, the variable a returns. 
> eval(z)
function()a+1

Why did a suddenly reappear again after it had already been replaced?




More information about the R-help mailing list