[R] lattice, trellis.device, dev.off() within a condition (seems t o be a bug)

Sundar Dorai-Raj sundar.dorai-raj at pdf.com
Thu Sep 18 17:08:14 CEST 2003



Marc Mamin wrote:

> Hi,
> 
> I have a strange issue under W2K;
> consider these two code extracts:
> 
> 1)
> 
> 	if(condition a){
> 	trellis.device(png,filename = filename_a,...
> 	xyplot(...
> 	dev.off()	
> 	}
> 
> 2) 
> 
> 	if(condition a){
> 	trellis.device(png,filename = filename_a,...
> 	xyplot(...
> 	}
> 	dev.off()	
> 
> 
> 
> In 1), The png file is generated, but empty; in 2), where I've taken the
> dev.off clause out of the condition block, my plot is fine
> 
> I've also tried following without success:
> 
> 	if(condition a){
> 	trellis.device(png,filename = filename_a,...
> 	xyplot(...
> 	}
> 	if(condition a){
> 	dev.off()	
> 	}
> 
> Is there a way to get a list of all open devices in order to close them
> outsid the condition blocks ??
> 

Try wrapping the xyplot call in a print() call.

e.g.

if(condition a) {
   trellis.device(...)
   print(xyplot(...))
   dev.off()
}

This is FAQ 7.24.

-sd




More information about the R-help mailing list