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

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Wed Jul 22 23:48:29 CEST 2020


On 22/07/2020 5:40 p.m., Helmut Schütz wrote:
> 
> 
> Duncan Murdoch wrote on 2020-07-22 21:42:
>> On 22/07/2020 1:25 p.m., Helmut Schütz wrote:
>>> [...]
>>> 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.
> Correct. However,
>    if (file.exists(paste0(png.path, "test.png"))) graphics.off()
> worked in the example but not in the package...
> 
>> 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.
> 
> The user is asked to provide a certain path indeed. Only if none is 
> provided, the fallback is "~/" (which is always writable). 

That disqualifies your package from inclusion on CRAN.  If no 
destination is provided and tempdir() isn't acceptable, you shouldn't 
write anything.  The user may be keeping an irreplaceable piece of 
information in "~/test.png", and your package would destroy it.  It's 
not your decision to make to trespass on the user's file space.

Duncan Murdoch


The package
> is intended for "common" users and not "R-geeks". If I would write to 
> tempdir(), I guess chances are pretty low that a user will be able to 
> locate the file.
> What I still fail to understand: CHECK laments about 
> grDevices::dev.off() in a certain man page, where I removed the argument 
> foo completely in one example (which is within \donttest{}). Hence, the 
> entire plotting routine is not executed at all. Furthermore, dev.off() 
> is nowhere used, only graphics.off() - now after file.exists().
> 
> Regards,
> Helmut
> 
> -- 
> Ing. Helmut Schütz
> BEBAC – Consultancy Services for
> Bioequivalence and Bioavailability Studies
> Neubaugasse 36/11
> 1070 Vienna, Austria
> Ehelmut.schuetz using bebac.at
> Whttps://bebac.at/
> Fhttps://forum.bebac.at/
>



More information about the R-package-devel mailing list