Reputation: 43
In R, the value of the variable MyVar should be evaluated and appear in the title of a simple R plot p.
MyVar<-0.23
The plot p is called using
plot(p, main = MyTitle)
My plot title needs a subscript and should look like this:
What is the correct statement for MyTitle= ? I tried dozens of variations using paste, expression, substitute, and bquote. Nothing seems to work...
Any help is highly appreciated! Thanks a bunch! Mark
Upvotes: 1
Views: 783
Reputation: 26225
I don't believe you can paste an expression to a variable (paste/print/cat/bquote/etc). As a workaround, you could use the "Fbelow=" expression as the title and use mtext to insert the value of MyVar, e.g.
MyVar<-0.23
plot(mtcars[2:3], main = expression('F'[below]*'='))
mtext(text = MyVar, side = 3, adj = 0.625, padj = -1.75, cex = 1.5)
Obviously this isn't ideal, but unless someone else has a clever way of solving your issue this will at least give you a potential option
Upvotes: 1