Hello All,

I try to use the attached code to produce a cross over plot. There are 13
subjects, 7 of them in for/sal group, and 6 of them in sal/for group. But in
xyplot, all the subjects are listed in both subgraphs. Could anyone help me
figure out how to get rid of the empty levels?

Thanks




library(lattice)

pef1 <- c(310,310,370,410,250,380,330,370,310,380,290,260,90)
pef2 <- c(270,260,300,390,210,350,365,385,400,410,320,340,220)
id <- c("1","4","6","7","10","11","14","2","3","5","9","12","13")
sequence <- c(rep('for/sal', 7), rep('sal/for', 6))
treat1 <- c(rep('for', 7), rep('sal', 6))
treat2 <- c(rep('sal', 7), rep('for', 6))
study <- data.frame(id, sequence, treat1, pef1, treat2, pef2)

studyLong <- as.data.frame(rbind(as.matrix(study[,c('id', 'sequence',
'treat1', 'pef1')]),
                                 as.matrix(study[,c('id', 'sequence',
'treat2', 'pef2')])))
colnames(studyLong) <- c('id', 'sequence', 'treat', 'pef')

xyplot(pef ~ id | sequence, groups=treat, data=studyLong,
auto.key=list(columns=2))

	[[alternative HTML version deleted]]

