[R] lattice command equivalent to points

Steven McKinney smckinney at bccrc.ca
Wed Sep 3 05:11:56 CEST 2008



This is close, but maybe not optimal lattice coding.
I haven't yet figured out how to suppress the x axis
labeling.

bwplot(yield ~ 1|year, panel = function(x, y, ...){panel.bwplot(x, y, ..., pch = "|"); panel.points(x, mean(y), ...,  pch=17)}, data = barley, horizontal = FALSE, xlab = "")

Steve McKinney


-----Original Message-----
From: r-help-bounces at r-project.org on behalf of Surai
Sent: Tue 9/2/2008 5:53 PM
To: r-help at r-project.org
Subject: [R] lattice command equivalent to points
 
Hello,
This is my first post to R-help so forgive me if I'm committing a fatal error somehow.  Feel free to let me know.
 
My question is this:  I would like to add a triangle to represent the mean in a box plot generated with the bwplot command.   How do I do this?  I am able to do this using the boxplot and points command but points does not work with bwplot.    If you run the following code in R, you'll see that I'm trying to reproduce graphs from method 2 by modifying code from method 1.
 
Thank you,
Surai Jones
 
 
library(lattice)
attach(barley)
 
#method 1
bwplot(yield~year, pch="|") 
 
#method 2
boxplot(yield~year)
mean.values<-tapply(yield,year, mean)
points(1:2, mean.values, pch = 17)


      
	[[alternative HTML version deleted]]



More information about the R-help mailing list