[R] substitute question

Gabor Grothendieck ggrothendieck at myway.com
Thu Mar 18 23:31:40 CET 2004



From:   Peter Dalgaard <p.dalgaard at biostat.ku.dk>
> (The real pain in these examples is that substitute autoquotes its
> expr argument. Therefore, when you want to modify an expression that
> is already stored in a variable, you need an extra outer layer of
> eval(substitute(...)) to poke the content of the variable into the
> inner substitute. An "esub" function with standard evaluation
> semantics would make this much easier.)

That is one of the frustrations of using substitute.  

The other is that even if you do perform two levels of substitute,
as I have been trying, you still can't count on it working for
an arbitrary unevaluated expression, as my examples show.  

Even putting aside the source attribute which is super confusing
until you know about it, all the solutions that I can see to 
the problem I presented are ugly.

(1) One can either pick apart the function using body, or 

(2) I  assume one could convert the function to text and 
paste together the correct substitute command with the text of 
the function inserted in its argument.   

The quote mechanism works but is not applicable if all you have
is the function itself (as you point out).

This is sooo frustrating.

Thanks to you, Tony and Thomas for all your help.




More information about the R-help mailing list