Marc Mamin
2003-Sep-18 14:41 UTC
[R] lattice, trellis.device, dev.off() within a condition (seems t o be a bug)
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 ??
Thanks for your help,
Marc Mamin
Sundar Dorai-Raj
2003-Sep-18 15:08 UTC
[R] lattice, trellis.device, dev.off() within a condition (seems t o be a bug)
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