[R] Can't write to an device after catching a warning.
Witold E Wolski
wewolski at gmail.com
Mon Mar 24 13:05:39 CET 2014
I have some code to handle warnings thrown because a device does not
support some features:
bla = tryCatch(
plot(d$ratio,-log10(d$pvals),col="#00000033",pch=19,xlab=xlab,
ylab=ylab),
warning=function(bla){dev.off(); return(1)}
)
if(!is.null(bla)){
plot(d$ratio,-log10(d$pvals),col=1,pch=19,xlab=xlab, ylab=ylab)
}
Problem with the code above is that I need to call dev.off() in the
function handling warnings
function(bla){dev.off(); return(1)}
The dev.off() in the tryCatch closes the device and alle commands send
to the device (i.e. par(mforw=c(2,2)) are lost.
However, if I don't call dev.off(), all what I write to the device
next (i.e. in the subsequent if statment) is'nt plotted. The device
appears to be "blocked".
regard
--
Witold Eryk Wolski
More information about the R-help
mailing list