From Martin Maechler <maechler@stat.math.ethz.ch>  Tue Jun 29 17:27:15 1999
From: Martin Maechler <maechler@stat.math.ethz.ch> (Martin Maechler)
Date: Tue, 29 Jun 1999 18:27:15 +0200
Subject: typeof ( substitute(expression(),..) ) -- musings
In-Reply-To: <x290932h11.fsf@blueberry.kubism.ku.dk> (message from Peter
 Dalgaard BSA on 29 Jun 1999 16:55:06 +0200)
References: <199906291258.OAA10869@sophie.ethz.ch> <x290932h11.fsf@blueberry.kubism.ku.dk>
Message-ID: <199906291627.SAA11269@sophie.ethz.ch>

[Relates to  math text / normal text mixing in plots ..]

Peter, I knew you'd know the answer quickly...

Anyway, one needs to be somewhat careful here [R version  pre 0.64.2]:

    typeof(print( e1 <-            expression(a + b))) # expression 
    typeof(print(se1 <- substitute(expression(a + b), list(a = 1)))) # language

    length(e1) # == 1
    length(se1)# == 2

    text.e <- function(x,y,e) {
        text(x,y,paste(deparse(substitute(e)),": "),adj=c(1,0))
	text(x,y,e, adj=0)
    }
    plot(1,type="n", axes= F)
    text.e(1,1.4, e1); text.e(1,1.3, se1); text.e(1,1.2, se1[[2]])

Which shows that you can't use the result of `substitute' directly, but
rather the 2nd element [[which is *still* not an expression !!]]

This is all +- S-plus (3.4) compatible 
     {{some details are NOT compatible; e.g. 
	     as.expression(se1[[2]])
       gives `what you expect' in R, but not in S-plus 3.4 or 5.0r3
     }}

  e1 is an expression	whereas
 se1 is a  call (aka "language" in R).

----
Is this documented anywhere? [blue book; language reference; ?? ]

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


typeof ( substitute(expression(),..) ) -- musings
Martin Maechler