Perhaps there is an obvious answer to this, but I can't seem to figure it out. I want to generate a sequence of plots, where a variable (say x) is changed from plot to plot. For each plot I'd like to have a title indicating the value of x. However, what I really want is to use expression to typeset some math. A simple example is I'd like to do something like expression(mu==x), where instead of the string "x" I'd like it to put the value of x (2.35, say). I can't figure out how to do this. Obviously I could treat each value individually and type in 2.35, etc, but I'd like to do this a little more elegantly, especially since I want to change the values of x quite a bit to explore some property. The closest I have come is to use paste: qq <- paste("expression(mu==",x,")",sep="") but can't figure out how to turn qq from a string to an expression. Thanks for any suggestions. dave -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
I am so sorry, I forgot the fundamental rule: always check the FAQ. Yes indeed, it contains the answer to my question. title(substitute(mu==x),list(x=x))) Again, I am sorry for cluttering the group with a FAQ. dave -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
David Marchette wrote:> > Perhaps there is an obvious answer to this, > but I can't seem to figure it out. I want to > generate a sequence of plots, where a variable > (say x) is changed from plot to plot. For each > plot I'd like to have a title indicating the value > of x. However, what I really want is to use > expression to typeset some math. A simple > example is I'd like to do something like > expression(mu==x), where instead of the string "x" > I'd like it to put the value of x (2.35, say). > I can't figure out how to do this. Obviously > I could treat each value individually and type > in 2.35, etc, but I'd like to do this a little > more elegantly, especially since I want to change > the values of x quite a bit to explore some > property. The closest I have come is to use > paste: qq <- paste("expression(mu==",x,")",sep="") > but can't figure out how to turn qq from a string > to an expression. Thanks for any suggestions.Try the nice function substitute(.), e.g.: x <- 2.35 plot(1:10, main=substitute(mu==x, list(x=x))) Regards, Uwe Ligges -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._