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))))


______________________________________________ [email protected] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to