I try to make a xyplot like the following: xyplot(y1+y2~id|groups, ...) I also want to calculate cor(y1,y2) in each group, print it on each panel. Does anyone know how to write panel function for this? Thanks, Aimin