[R] plotmath question
Thomas Lumley
tlumley at u.washington.edu
Sat Mar 19 00:19:49 CET 2005
On Fri, 18 Mar 2005, Berton Gunter wrote:
>
> 2) The plotmath Help state that expressions can be used for axis labels, so
> I would have expected the above to work without the eval()call -- but it
> does not. Would someone kindly explain to me why not -- i.e., what I have
> misunderstood. That is, to be clear, why does the following not work:
Because substitute() doesn't evaluate its argument: the result is not an
expression but a call to the expression() function.
An example where it is clearer what is going on
substitute(log(x),list(x=1))
doesn't return a number, even though log() returns a number. It returns a
call to log() that still has to be evaluated
-thomas
> for(i in seq(-3,to=3))
> axis(1,at=i, lab=switch(sign(i)+2,
> substitute(expression(mu-j*sigma),list(j=i)),
> expression(mu),
> substitute(expression(mu+j*sigma),list(j=i))))
>
More information about the R-help
mailing list