[R-pkg-devel] Error in CHECK caused by dev.off()
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Wed Jul 22 21:42:55 CEST 2020
On 22/07/2020 1:25 p.m., Helmut Schütz wrote:
> Hi Serguei,
>
> Serguei Sokol wrote on 2020-07-22 15:51:
>> Hmm... I see 2 possibilities for still getting an error while the
>> concerned part of code is not supposed to be run:
>>
>> - either you are running not updated version of your package;
>
> I _can_ built the package and it runs as intended. Only the CHECK throws
> the error.
>
>> - or the error comes from some other place of the code.
>
> Closing the device is required only _once_ in the entire package.
> In my NAMESPACE I have (and had in all previous versions):
> importFrom(grDevices, png, graphics.off, dev.list, dev.off)
>
>> Sorry but without a minimal reproducible example I cannot help more.
>
> The problem is that I cannot reproduce it as well. Only CHECK laments
> about dev.off() which I changed to graphics.off() in the meantime.
>
> library(grDevices)
> foo <- TRUE # shall we plot?
> png.path <- "~/" # user's home folder
> png.path <- normalizePath(png.path)
> if (foo) {
> png(paste0(png.path, "test.png"), width = 480, height = 480,
> pointsize = 12)
> }
> plot(x = 0:1, y = 0:1, type = "l", xlab = "x", ylab = "y")
> if (foo) {
> graphics.off()
> }
You don't test whether the call to png() succeeded. During a check, it
probably wouldn't, because you aren't allowed to write to "~/". Your
package should be writing to tempdir(), or a location entered by the user.
Duncan Murdoch
More information about the R-package-devel
mailing list