John Maindonald
2001-May-07 10:24 UTC
[R] Symbolic substitution of expressions into expressions
In the following titletxt <- substitute(paste(tx, tilde(y) == sqrt(y)), list(tx="Replace y by ")) I'd like to be able to replace e.g. sqrt(y) by a symbol or symbolic expression that has the effect of inserting sqrt(y) into the place that it occupies. This would allow me to put an arbitrary expression into that position. [One can use text() or mtext() etc. to place titletxt on a graph.] Any clues would be most welcome. John Maindonald. John Maindonald email : john.maindonald at anu.edu.au Statistical Consulting Unit, phone : (6125)3998 c/o CMA, SMS, fax : (6125)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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2001-May-07 12:16 UTC
[R] Symbolic substitution of expressions into expressions
John Maindonald <john.maindonald at anu.edu.au> writes:> In the following > > titletxt <- substitute(paste(tx, tilde(y) == sqrt(y)), > list(tx="Replace y by ")) > > I'd like to be able to replace e.g. sqrt(y) by a symbol or > symbolic expression that has the effect of inserting sqrt(y) > into the place that it occupies. This would allow me to put an > arbitrary expression into that position. [One can use text() or > mtext() etc. to place titletxt on a graph.] > > Any clues would be most welcome.titletxt <- substitute(paste(tx, tilde(y) == my.y), list(tx="Replace y by ",my.y=quote(sqrt(y)))) -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
John Maindonald
2001-May-09 04:07 UTC
[R] Symbolic substitution of expressions into expressions
I inquired> In the following > > titletxt <- substitute(paste(tx, tilde(y) == sqrt(y)), > list(tx="Replace y by ")) > > I'd like to be able to replace e.g. sqrt(y) by a symbol or > symbolic expression that has the effect of inserting sqrt(y) > into the place that it occupies. This would allow me to put an > arbitrary expression into that position. [One can use text() or > mtext() etc. to place titletxt on a graph.] > > Any clues would be most welcome.to which Peter Dalgaard helpfully replied << titletxt <- substitute(paste(tx, tilde(y) == my.y), list(tx="Replace y by ",my.y=quote(sqrt(y))))>>This does not quite go as far as I want.> tx2 <- expression(x^2) > qx2 <- quote(x^2) > tx2expression(x^2)> qx2x^2 Setting my.y = qx2 places the latexed version of x^2 into the text string and hence on the graph, while my.y=quote(tx2) places "expression(x^2)" into the text string. Is there any way to get from expression(x^2) or the text string "x^2" to quote(x^2)? John Maindonald. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._