The example code below allows the plotting of three different groups per panel.  I can't fathom how to write the panel function to add an additional line for each group, which in this case is just the mean Y value for each group within  each panel.  (i.e. there'd be six lines per panel.)
Spent all day working on it and searching the archives to no avail!  Yikes.
Any help would be greatly appreciated!
Michael Folkes

#________________________
#This builds fake dataset

years<-2000:2006
weeks<-1:20
yr<-rep(years,rep(length(weeks)*6,length(years)))
wk<-rep(weeks,rep(6,length(weeks)))
temp<-rep(4:9,length(years)*length(weeks))
yvar<-round(rnorm(length(years)*length(weeks)*6,mean=30,sd=4),0)
xvar<-(rnorm(length(years)*length(weeks)*6)+5)/10

df<-data.frame(year=yr,week=wk,temp=temp,	yvar=yvar,	xvar=xvar)
#________________________

library(lattice)
df$year2<-as.factor(df$year)
df$week2<-as.factor(df$week)
df<-df[df$temp %in% c(5,7,9),]
xyplot(yvar~year|week2,data=df,layout = c(4, 5), as.table=TRUE,
	type='l',
	groups=temp ,
      panel = function(x, y,groups, ...) {
		panel.superpose(x,y,groups,...)
		panel.xyplot(x,rep(mean(y),length(x)),type='l',lty=3) #<- only generates the panel mean
      }
)

_______________________________________________________
Michael Folkes
Salmon Stock Assessment
Canadian Dept. of Fisheries & Oceans     
Pacific Biological Station
3190 Hammond Bay Rd.
Nanaimo, B.C., Canada
V9T-6N7
Ph (250) 756-7264 Fax (250) 756-7053  folkesm@pac.dfo-mpo.gc.ca


	[[alternative HTML version deleted]]

