1

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: enter image description here

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

M. Brink
  • 43
  • 6
  • [answer to this question could help](https://stackoverflow.com/questions/36470026/using-as-subscript-in-plotmath) `plot(1, main = bquote(F[below]==.(MyVar)))` – rawr Feb 18 '21 at 00:40

1 Answers1

1

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)

example.png

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

jared_mamrot
  • 22,354
  • 4
  • 21
  • 46