Dear Marius, Try this: plot.list = lapply(1:10,
function(i) xyplot(i~i,type="p",xlim=c(0,11),panel=function(...) { panel.xyplot(...); panel.abline(v=i)}) ) plot.list[[3]] I imagine it will work for Mr Luftjammer, too. Rex -----Original Message----- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Marius Hofert Sent: Tuesday, February 08, 2011 6:37 AM To: Help R Subject: [R] "strange" behavior of panel.abline inside a for-loop Dear expeRts, I would like to create a list of lattice xyplots. Here is the minimal example: library(lattice) plot.list <- vector("list", 10) for(i in 1:10){ plot.list[[i]] <- xyplot(i~i, type="p", xlim=c(0,11), panel=function(...){ panel.xyplot(...) panel.abline(v=i) }) } plot.list[[3]] As you can see, the vertical line is *always* printed at x=10 [and not at x=i]. Why? Cheers, Marius ______________________________________________ R-help@r-project.org 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. message may contain confidential information. If you are not the designated recipient, please notify the sender immediately, and delete the original and any copies. Any use of the message by you is prohibited. ______________________________________________ R-help@r-project.org 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.