13

I'm trying to annotate a plot with R² value and significance coding, but I can't pass * as a symbol and not as the juxtaposition operator.

I've tried ?plot.math, here is what I tried

plot(1:10,1:10)
text(6,4,expression(R^2==8))
text(6,4,expression(R^2==8^{**}))
Error: unexpected '^' in "text(6,4,expression(R^2==8^{**"
csgillespie
  • 59,189
  • 14
  • 150
  • 185
fstevens
  • 1,287
  • 1
  • 17
  • 28

1 Answers1

14

You need to use paste inside your expression:

text(4,6,expression(paste(R^2==8^"**")))

or

text(6,4,expression(paste(R^2==8, "**")))

enter image description here

csgillespie
  • 59,189
  • 14
  • 150
  • 185
  • For any searchers who come here like me: I was trying to imitate LaTeX where `f^*(x)` looks the best and couldn't figure out how to munge the example from `?plotmath` into this (?`paste({f^, '*', }(x))`? doesn't parse); simply using `paste(f, '*', (x))` looks just fine, however. – MichaelChirico Jul 04 '18 at 09:00