[R] xyplot Graphic Help

Shawn Way shawnway at yahoo.com
Mon Oct 2 03:38:47 CEST 2006


I have the following graphic where I drop unused factors in the x axis, however I cannot get the first point on the second panel. It seems shifted. Any ideas? 

The example is below: 

data <- data.frame( 
Room=as.factor(c(132,132,132,132,132,132,132,132,132,196,196)), 
Sample=as.factor(c("A","B","C","J","K","L","M","N","O","B","C")), 
Particulates=c(90,300,400,300,400,300,500,200,300,14,52), 
Class=as.factor(c(100000,100000,100000,100000,100000,100000,100000,100000,100000,10000,10000)) 
) 
a <- data$Class 
print( 
xyplot(Particulates~Sample|Room, 
data=data, 
# groups=Room, 
type="p", 
xlab=list(label="Sample Site",cex=3), 
ylab=list(label=expression(paste("Particles" >= "0.5 ",mu,"m/ft"^"2")),cex=3), 
ylim=c(-100,1200), 
# index.cond=list(c(2,1)), 
scales=list(x=list(relation="free", cex=2),y=list(cex=2)), 
prepanel=function(x,y,... ) { 
# yy <- y[,drop=TRUE] 
xx <- x[,drop=TRUE] 
list(xlim=levels(xx), 
# ylim=levels(yy), 
xat=sort(unique(as.numeric(xx))) 
# yat=sort(unique(as.numeric(yy))) 
) 
}, 
panel=function(x,y,subscripts,m=a, ...) { 
# yy <- y[,drop=TRUE] 
panel.xyplot(x,y,...) 
panel.abline(h=m[subscripts],col="red") 
panel.abline(h=mean(y,na.rm=TRUE),col="green") 
# panel.segments(x,y,...) 
} 
) 
)



More information about the R-help mailing list