[R] Complex superscript plot text

Uwe Ligges ligges at statistik.uni-dortmund.de
Fri Mar 16 10:36:14 CET 2007


* Bob Farmer <rfarmer at uoguelph.ca> [070316 05:57]:
> Hi all:
> 
> I would like to create a line of plot margin text (using mtext() ) that 
> features both a superscript and a subset of an object.  However, I 
> cannot seem to do both things at once, nor have I found a way to paste 
> the two results together.
> 
> (I pull the object subset because this is part of a for-next loop to 
> make multiple graphs)
> 
> This example doesn't give me what I want from mtext():
> 
> GoodnessOfFits<-c(1, 0.75)
> 
> graphNumber<-1  #first loop of the for-next loop (not shown)
> 
> x<-seq(-10, 10, 1)
> y<-(x^2)
> plot(x,y)
> lines(x, predict(lm(y~I(x^2))))
> mtext(text=
> 	expression(R^2 * ": "* GoodnessOfFits[graphNumber]))
> 

plot(x,y)
lines(x, predict(lm(y~I(x^2))))
mtext(text = substitute(R^2 == GF, list(GF = GoodnessOfFits[graphNumber])), line = 1)
 

Uwe Ligges


> I recognize that in this example, I could extract the R-squared value 
> from the model in each loop, however this does not apply to my more 
> complicated real scenario.
> 
> Any suggestions?
> 
> Thanks.
> --Bob Farmer
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list