Re: [R] Lattice plot within a "for" loop does not happen?

From: Barry Rowlingson <>
Date: Sat 14 May 2005 - 00:24:04 EST

> BUT, when I stick this in a loop, I get a bunch of blank graphics
> devices. This happens even if the loop only executes once. I could just
> go through and do these one by one, but I was curious if I was
> overlooking something obvious. Thank you for any advice.

  You're overlooking something like line 800 of the documentation for xyplot:


      An object of class ``trellis''. The `update' method can be used to
      update components of the object and the `print' method (usually
      called by default) will plot it on an appropriate plotting device.

  xyplot doesn't actually make any marks on the screen. Oh no. It returns an object. You have to make that object make the marks on the screen. This happens automatically when you run something interactively, but not inside a function.

  So wrap your xyplot call in a print() function inside your loop:

  for(i in 1:10){

  Its probably in the R-FAQ as well, since my original feeling was that this behaviour was chosen in order to confuse people and see how many people read the FAQ... :)

Baz mailing list PLEASE do read the posting guide! Received on Sat May 14 00:34:08 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:45 EST