[R] Writing text in lattice graphics

Luis Torgo ltorgo at liacc.up.pt
Tue Apr 23 18:05:04 CEST 2002


I'm trying to obtain a set of regression lines obtained for different values 
of a factor using lattice. I would like to add a string to each panel showing 
the R^2 value of the respective line, but I'm having difficulties positioning 
the text (namely on which coordinates to give to the "ltext" function).
Here is what I'm using (I've used ?? for the things I would like you to be so 
kind to help me on how to fill in).

>  xyplot(O2 ~ Am | Site, data = mydata, scales=list(x='free'),
	panel=function(x,y,...) {
		panel.xyplot(x,y,...)
		panel.lmline(x,y,...)
		ltext(??, ??, round(summary(lm(y ~ x))$r.squared,3))
	})

I would like the R^2 values to appear in the top left corner of each of the 
panels I get.
I've tried fixed values for the "x", "y" parameters of "ltext", but as I'm 
using different X scales for each panel things get messy...

I'm using R 1.4.1 on a Windows 2000 machine.

Thank you in advance.

-- 
Luis Torgo
    FEP/LIACC, University of Porto   Phone : (+351) 22 607 88 30
    Machine Learning Group           Fax   : (+351) 22 600 36 54
    R. Campo Alegre, 823             email : ltorgo at liacc.up.pt
    4150 PORTO   -  PORTUGAL         WWW   : http://www.liacc.up.pt/~ltorgo
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list