Hi All,

I have a quick question and any help is greatly appreciated. For the following data when I try to produce the image using xyplot function in lattice package, the key has 4 rows instead of 2. Can anyone tell me what I'm doing wrong and what is the way to fix the problem. Here the code that I'm running

studyData <- as.data.frame(t(structure(c(
"A",0,4.477,
"A",3,0.711,
"A",6,0.597,
"A",12,0.216,
"A",24,2.716,
"A",48,1.418,
"A",72,0.377,
"A",96,0.494,
"A",168,0.181,
"A",336,0.388,
"A",504,0.217,
"A",672,0.128,
"C",0,1.0,
"C",3,0.987,
"C",6,0.593,
"C",12,1.113,
"C",24,4.412,
"C",48,0.451,
"C",72,0.841,
"C",96,0.688,
"C",168,0.305,
"C",336,0.266,
"C",504,0.257,
"C",672,0.52,
), .Dim=c(3,24))));
colnames(studyData) <- c('treatment','timeInterval','foldChange');

treatmentCount <- length(levels(studyData$treatment));
studyData[c("timeInterval", "foldChange")] <- lapply(studyData[c("timeInterval", "foldChange")], function(x) as.numeric(levels(x)[x]));

studyData <- studyData[do.call("order", studyData), ];
trellis.par.set(theme = col.whitebg());

print(xyplot(foldChange ~ timeInterval, data=studyData, type='b', groups = treatment, 
pch=1:treatmentCount, 
key = list(points = list(Rows(trellis.par.get("superpose.line"),  c(1:treatmentCount)), col=Rows(trellis.par.get("superpose.line"),  c(1:treatmentCount))$col, pch = 1:treatmentCount, type='b'), 
	   cex = trellis.par.get("superpose.symbol")$cex[1:treatmentCount], 
	   text = list(lab = as.character(unique(studyData$treatment))), 
	   columns = 1, 
	   border=TRUE, 
	   space="top"), 
ylab="Relative Change(1=12.50%tile)", 
xlab="Time Interval (hour)"));

Thanks,
Sandeep.

	[[alternative HTML version deleted]]


