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

George W. Gilchrist gwgilc at wm.edu
Fri May 13 16:09:16 CEST 2005


I am trying to do a series of xyplots plots, using a "for" loop to  
substitute the appropriate variables for each plot. The basic command  
works fine by itself and produces a nice plot:

 > i<-3
 >  trellis.device(theme="col.whitebg")
 >  xyplot(as.formula(paste(tmp00[2*i], "~ ", tmp00[(2*i)-1],
+                             "|Blastomere+Phenotype", sep="")),
+         data=tmp1,
+         panel=function(x,y,...){
+           panel.xyplot(jitter(x), jitter(y), pch=16, col="red")
+           if (max(x, na.rm=T)!=0.0) panel.xyplot(x, y, type="r",  
lwd=2)
+        })
 >

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.

==================================================================
George W. Gilchrist                        Email #1: gwgilc at wm.edu
Department of Biology, Box 8795          Email #2: kitesci at cox.net
College of William & Mary                    Phone: (757) 221-7751
Williamsburg, VA 23187-8795                    Fax: (757) 221-6483
http://gwgilc.people.wm.edu/




More information about the R-help mailing list