[R-pkg-devel] Error in CHECK caused by dev.off()

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Jul 22 16:59:36 CEST 2020


On 22/07/2020 8:36 a.m., Helmut Schütz wrote:
> Dear all,
> 
> I have two variables, foo and bar. The first is TRUE if a png should be
> created and the second is TRUE if an already existing one should be
> overwritten.
> At the end of the plot I had
> if (foo | (foo & bar)) dev.off()
> This worked as expected in all versions of my package built in R up to
> v3.6.3. However, when I CHECK the package in v4.0.2 I get:
>   > grDevices::dev.off()
> Error in grDevices::dev.off() :
>     cannot shut down device 1 (the null device)
> Execution halted
> 
> I tried:
> if (foo | (foo & bar)) {

Assuming that foo and bar are each length one variables, this test is 
logically equivalent to

   if (foo) {

Is that really what you intended?

Duncan Murdoch

>     dev <- dev.list()
>     if (!is.null(dev)) {
>       if (dev == 2) invisible(dev.off())
>     }
> }
> without success (same error).
> 
> Even the more general
> if (foo | (foo & bar)) {
>     graphics.off()
> }
> did not work.
> 
> The plot is called only in an example of one man-page -- though embedded
> in \donttest{}.
> Even if I set both foo and bar to FALSE (i.e., the respective part of
> the code should not be executed at all), I get the same error.
> 
> Any ideas/suggestions?
> 
> Regards,
> Helmut
>



More information about the R-package-devel mailing list