[R] superscript troubles

Peter Dalgaard P.Dalgaard at biostat.ku.dk
Mon Nov 2 16:45:15 CET 2009


Jacob Kasper wrote:
> I know that this has been revisited over and over, yet I cannot figure out
> how to solve this case of superscript troubles...
> I would like the 2 in r2 to be superscript, yet I am pasting text before and
> after it. I have tried several variations but have not solved this yet, any
> suggestions?
> 
> legend (bty =
> "n","topright",paste("r2=",round(summary(lat_x)$r.squared,digits=3),",
> P=",round(coefficients(summary(lat_x))[2,4], digits=3)))
> Thank you
> Jacob

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...)

-- 
   O__  ---- Peter Dalgaard             Øster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics     PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark      Ph:  (+45) 35327918
~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk)              FAX: (+45) 35327907




More information about the R-help mailing list