[R] "strange" behavior of panel.abline inside a for-loop

Peter Ehlers ehlers at ucalgary.ca
Tue Feb 8 16:22:14 CET 2011


On 2011-02-08 06:28, Marius Hofert wrote:
> Dear Karl,
>
> thanks for your answer.
>
> I am still wondering why the point "i~i" is plotted at "i" but not the vertical line? And how I can plot the vertical line at "i". Do you know a solution?

Marius, try this:

  plot.list <- vector("list", 3)
  for(i in 1:3){
     plot.list[[i]] <- xyplot(i~i, type="p", xlim=c(0,11),
     panel=function(x, y,...){
	panel.xyplot(x, y,...)
	panel.abline(v = x)
     })
  }
plot.list[[1]]

Peter Ehlers

>
> Cheers,
>
> Marius
>
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list