Johannes Graumann
2008-Jan-17 08:26 UTC
[R] multiple text placements and expressions revisited
Hi all, I asked something like this earlier but decided that a proper minimal example might be helpfull ;0) Why does this work with regards to the expression (substitution): require(stats) plot(cars) text(5,120,labels=substitute(i^{z+phantom()}*"("*a*" AMU)",list(i="yx",z=2,a=0))) text(c(5,5),c(115,110),labels=c("One","Two")) But adding this (using a vector of expressions/substitutions) fails to print the expression correctly: text(c(5,5),c(105,100),labels=c(substitute(i^{z+phantom()}*"("*a*" AMU)",list(i="yx",z=2,a=0)),"Three")) This is a bug, no? Joh
Prof Brian Ripley
2008-Jan-17 09:02 UTC
[R] multiple text placements and expressions revisited
On Thu, 17 Jan 2008, Johannes Graumann wrote:> Hi all, > > I asked something like this earlier but decided that a proper minimal > example might be helpfull ;0) > > Why does this work with regards to the expression (substitution): > > require(stats) > plot(cars) > text(5,120,labels=substitute(i^{z+phantom()}*"("*a*" > AMU)",list(i="yx",z=2,a=0))) > text(c(5,5),c(115,110),labels=c("One","Two")) > > But adding this (using a vector of expressions/substitutions) fails to print > the expression correctly: > > text(c(5,5),c(105,100),labels=c(substitute(i^{z+phantom()}*"("*a*" > AMU)",list(i="yx",z=2,a=0)),"Three")) > > This is a bug, no?Yes, but not where you appear to think it is. 'labels' is not an expression: check it by typeof(). Using expression() in place of c() will give what I think you intended. -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595