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 -- Jacob Kasper http://twitter.com/Protect_Oceans 66°04' N 23°07' W Coastal & Marine Management Master's Student University Centre of the Westfjords Sundstræti 14 37 Devens Rd Ísafjörður, 400 Swampscott, MA 01907 Iceland USA [[alternative HTML version deleted]]
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>:> 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 > > -- > Jacob Kasper > http://twitter.com/Protect_Oceans > 66?04' N > 23?07' W > Coastal & Marine Management Master's Student > University Centre of the Westfjords > > Sundstr?ti 14 ? ? ? ? ? ? ? ? ? ? ? ? ? ?37 Devens Rd > ?safj?r?ur, 400 ? ? ? ? ? ? ? ? ? ? ? ? ? Swampscott, MA 01907 > Iceland ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? USA > > ? ? ? ?[[alternative HTML version deleted]] > > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. > >
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 > JacobYou 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