[R] help with superscripts in simple plots

Steve_Friedman at nps.gov Steve_Friedman at nps.gov
Wed Jul 1 16:00:01 CEST 2009


Hello All,

When I use the following lines of code to create a plot  and add labels
with R-square values the labels have a superscripted R2.

  library(lattice)

 xyplot(PropHatchedNests$Phatched + PropHatchedNests$PropNests +
PropHatchedNests$meanHSI + PropHatchedNests$RelMeanEggsNest ~
PropHatchedNests$Year, type = "b",
    scales=list(tick.number=length(PropHatchedNests$Year)), ylab="Score",
xlab="Year", pch=c(1,4,5), col= c("black","blue", "red", "darkgreen"),
           lty = c(1,12,9,16),  main="Shark Slough Alligators")
      trellis.focus()
        panel.text(x=1994, y=0.45, labels="Relative Number Nests",
cex=0.75)
           panel.text(1994, y=0.4, label=bquote(R^2 == .(R17)), cex=0.75 )
        panel.text(x=1996, y=0.8, labels="Mean API", cex = 0.75)
           panel.text(x=1996, y=0.13, labels="Proportion of Hatched Eggs" ,
cex=0.75)
             panel.text(1996,  y=0.08, label=bquote(R^2 == .(R55)),
cex=0.75)
        panel.text(x=1989, y=1.0, labels="Relative Mean Number Eggs Per
Nests Per Year" , cex = 0.75)
             panel.text(x= 1989, y = 0.93, label=bquote(R^2 == .(R44)), cex
= 0.75)
       trellis.unfocus()


But when I use the following in a much simpler plot I can't seem to get it
to work correctly.   Is there a different way of using text and
superscripts that are not associated with lattice plots ?

plot(PropHatchedNests$PropNests, PropHatchedNests$meanHSI, ylab="Mean HSI",
xlab="Proportion of Nests", xlim=c(0,1), ylim=c(0,1),
   text(0.25, 0.9, "B       R^2 = 0.17"))
    abline(lm(PropHatchedNests$meanHSI ~ PropHatchedNests$PropNests))

All suggestions will be appreciated.

Running:  R version 2.8.1 (2008 - 12-22) Windows XP

Thanks
Steve

Steve Friedman Ph. D.
Spatial Statistical Analyst
Everglades and Dry Tortugas National Park
950 N Krome Ave (3rd Floor)
Homestead, Florida 33034

Steve_Friedman at nps.gov
Office (305) 224 - 4282
Fax     (305) 224 - 4147




More information about the R-help mailing list