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"
You probably have missing values in your y data. Try: ... panel.abline(h=mean(y,na.rm=TRUE)) ... -- Bert Gunter Genentech Non-Clinical Statistics South San Francisco, CA "The business of the statistician is to catalyze the scientific learning process." - George E. P. Box> -----Original Message----- > From: r-help-bounces at stat.math.ethz.ch > [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Martin > Henry H. Stevens > Sent: Tuesday, December 20, 2005 10:30 AM > To: r-help at stat.math.ethz.ch > Subject: [R] panel function > > 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" > > ______________________________________________ > 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 >
Hi Bernard, Your solution was exactly right. I could have sworn I tried also panel.abline(a=mean(y,na.rm=TRUE), b=0) and, although it works now, I must have done something wrong such that it did not work. THANK YOU On Dec 20, 2005, at 2:18 PM, Berton Gunter wrote:> You probably have missing values in your y data. Try: > ... > panel.abline(h=mean(y,na.rm=TRUE)) > ... > > -- Bert Gunter > Genentech Non-Clinical Statistics > South San Francisco, CA > > "The business of the statistician is to catalyze the scientific > learning > process." - George E. P. Box > > > >> -----Original Message----- >> From: r-help-bounces at stat.math.ethz.ch >> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Martin >> Henry H. Stevens >> Sent: Tuesday, December 20, 2005 10:30 AM >> To: r-help at stat.math.ethz.ch >> Subject: [R] panel function >> >> 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" >> >> ______________________________________________ >> 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 >> >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"