[R] panel function

Martin Henry H. Stevens hstevens at muohio.edu
Tue Dec 20 19:30:21 CET 2005


R v. 2.2.0 on Mac OS 10.4.3
lattice v. 0.12-11

I am trying to add a horizontal panel mean line to a series of panels  
in a trellis plot (i.e. a horizontal line at the mean of  y for each  
individual panel). I have tried innumerable ways to do this,  
including the code below, but if it works at all, it merely puts a  
horizontal line in the last panel.

xyplot(diss ~ Nut-7|Size, data=dathdiss, pch=1, jitter.data=TRUE,  
panel=function(x,y,...){
	panel.xyplot(x,y)
	panel.abline(a=mean(y),b=0) #This results in the correct line in the  
last panel, but no other lines at all.
	})

Any and all thoughts are appreciated.
Thank you kindly,
Hank

Dr. Martin Henry H. Stevens, Assistant Professor
338 Pearson Hall
Botany Department
Miami University
Oxford, OH 45056

Office: (513) 529-4206
Lab: (513) 529-4262
FAX: (513) 529-4243
http://www.cas.muohio.edu/~stevenmh/
http://www.muohio.edu/ecology/
http://www.muohio.edu/botany/
"E Pluribus Unum"




More information about the R-help mailing list