[R] text(x,y,expression(sqrt(txt))), where txt is a text string
John Maindonald
john.maindonald at anu.edu.au
Thu Aug 12 07:34:58 CEST 1999
My question was supposed to have been (I had plot() instead of text()!)
I have e. g.
> txt <- "abcd"
In
> text(x,y, expression(sqrt(txt)))
I want txt to be evaluated, i. e. to get sqrt(abcd) plotted,
(with the square root symbol replacing sqrt, of course).
Is there a way to achieve this?
Berwin Turlach provided the following:
> txt <- "abcd"
> text(4.5,4.5,as.expression(substitute(sqrt(txt),list(txt=txt))))
Bill Venables made another suggestion:
i. e.
> txt <- as.name("abcd")
> ex <- expression(sqrt(txt))
> ex
expression(sqrt(txt))
> ex[[1]][[2]] <- eval(ex[[1]][[2]])
> ex
expression(sqrt(abcd))
>
I think what you want in the driver's seat is a name object, not a text
string. Evaluating the name of a name object gives you a name, if I make
myself clear....
One then invokes text(x,y,ex)
Neither of these seem to work in 0.64.2
Thanks for the prompt helpful responses.
John Maindonald email : john.maindonald at anu.edu.au
Statistical Consulting Unit, phone : (6249)3998
c/o CMA, SMS, fax : (6249)5549
John Dedman Mathematical Sciences Building
Australian National University
Canberra ACT 0200
Australia
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help 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-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list