On 6/28/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > I would like to add a reference line to lattice graphs, with the reference > line > being different according to the factor level. > > Example : Draw 3 dotplots for "a","b" and "c" factors, and then add an > horizontal line at y=10 for panel "a", y=8 for panel "b" and y=6 for panel > "4" > > I tried the code below, but this draw all three reference lines for each > panel. > How do I index the current panel to chose the right reference vector value ? > > dat<-data.frame(id=rep(c("a","b","c"),4),val=1:12,quand=rep(c("t1","t2","t3","t4"),each=3)) > ref<-c(10,8,6) > plot.new() > datplot<-dotplot(val~quand|id,data=dat,panel=function(...){ > panel.dotplot(...) > panel.abline(h=ref) > }) > print(datplot)
dotplot(val~quand|id,data=dat,panel=function(...){ panel.dotplot(...) panel.abline(h = ref[packet.number()]) }) (Things are more complicated if you have more than one conditioning variable.) -Deepayan ______________________________________________ R-help@stat.math.ethz.ch mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.