Hi, all. I know that this is probably something that others have asked, but I can't find a reference in either the FAQ or the help pages. I'm trying to find a way to put Greek letters as a label of the plot *with* a value from the data. Previously I've used pasted and the word "rho". * paste("rho=", cor2[i]) will produce a label of "rho=0.74", or whatever. But if I use 'substitute' or 'evaluate' commands in order to get a real Greek letter, I lose the ability to paste it with a data value. Any ideas? Thanks, Jo Jo Hardin Assistant Professor Department of Mathematics Pomona College 610 N. College Ave. Claremont, CA 91711 909-607-8717 jo.hardin@pomona.edu ------------------------------------------------------------- This message has been scanned by Postini anti-virus software. [[alternative HTML version deleted]]
Johanna Hardin wrote:> > * paste("rho=", cor2[i])> will produce a label of "rho=0.74", or whatever. But if I use > 'substitute' or 'evaluate' commands in order to get a real Greek letter, > I lose the ability to paste it with a data value.Use parse() to turn that text into an expression. And use '==': > rho=0.78 > plot(1:10,main=parse(text=paste("rho == ",rho))) Not sure where your label is going, but the same thing should work for axes and text labels. Baz
On Tue, 2005-11-01 at 05:20 -0800, Johanna Hardin wrote:> Hi, all. I know that this is probably something that others have asked, > but I can't find a reference in either the FAQ or the help pages. > > I'm trying to find a way to put Greek letters as a label of the plot > *with* a value from the data. Previously I've used pasted and the word > "rho". > > * paste("rho=", cor2[i]) > > will produce a label of "rho=0.74", or whatever. But if I use > 'substitute' or 'evaluate' commands in order to get a real Greek letter, > I lose the ability to paste it with a data value.> Any ideas?> Thanks, JoTry this: cor2 <- 0.74 plot(1:5) title(bquote(rho == .(cor2))) See ?plotmath and ?bquote for more information, noting the use of the .(Variable) syntax for variable substitution. HTH, Marc Schwartz