Skip to content

superscript troubles

3 messages · Jacob Kasper, Baptiste Auguie, Peter Dalgaard

#
Hi,

Try this,

x = rnorm(1)
y = rnorm(1)
leg = bquote(r^2*"="*.(round(x,digits=3))*", P="*.(round(y, digits=3)))
plot.new()
legend (bty ="n","topright",legend=leg)

HTH,

baptiste

2009/11/2 Jacob Kasper <jacobkasper at gmail.com>:
#
Jacob Kasper wrote:
You want the whole thing to be an expression. To insert values, bquote()
is your friend. Something like this

legend(bty="n", "topright",
   bquote(r^2 == .(round(summary(lat_x)$r.squared,digits=3)
          * "," *
          P == .(round(coefficients(summary(lat_x))[2,4], digits=3)
          )
)

(untested, if you want us to test, give us a reproducible example...)