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

Helmut Schütz he|mut@@chuetz @end|ng |rom beb@c@@t
Wed Jul 22 23:40:31 CEST 2020



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). 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
E helmut.schuetz using bebac.at
W https://bebac.at/
F https://forum.bebac.at/


	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list