Thierry Onkelinx
2018-Nov-20 13:16 UTC
[Rd] problematic dev.off() after running examples without plots
Dear all, When running R CMD check on our package, we get an error on the examples. Error in grDevices::dev.off() : cannot shut down device 1 (the null device) None of the examples in our package generates plots. grDevices::dev.off() is code added by R CMD check. A workaround is to have at least one example which has some plot. Is there a better solution? We are using R 3.5.1 Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkelinx at inbo.be Havenlaan 88 bus 73, 1000 Brussel www.inbo.be /////////////////////////////////////////////////////////////////////////////////////////// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /////////////////////////////////////////////////////////////////////////////////////////// <https://www.inbo.be> [[alternative HTML version deleted]]
Martin Maechler
2018-Nov-21 09:44 UTC
[Rd] problematic dev.off() after running examples without plots
>>>>> Thierry Onkelinx via R-devel >>>>> on Tue, 20 Nov 2018 14:16:20 +0100 writes:> Dear all, When running R CMD check on our package, we get > an error on the examples. > Error in grDevices::dev.off() : > cannot shut down device 1 (the null device) > None of the examples in our package generates > plots. grDevices::dev.off() is code added by R CMD > check. Yes, but there's also code added at the very beginning of the examples R script ( <pkg>-Ex.R ) which opens a pdf device: grDevices::pdf.options(width = 7, height = 7, paper = "special", reset = TRUE) grDevices::pdf(paste(pkgname, "-Ex.pdf", sep=""), encoding = "ISOLatin1") and so things should work and do work well for packages without any plots. You must be doing something particularly strange in some of *your* examples such as closing all existing devices -- something you should not do: As a good citizen you close graphic devices that you open but not others. > A workaround is to have at least one example which > has some plot. Is there a better solution? Yes, find the example in your package which does the above "strange thing" and modify that. Best, Martin Maechler ETH Zurich and R Core Team > We are using R 3.5.1 > Best regards, > ir. Thierry Onkelinx Statisticus / Statistician > Vlaamse Overheid / Government of Flanders INSTITUUT VOOR > NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE > AND FOREST Team Biometrie & Kwaliteitszorg / Team > Biometrics & Quality Assurance thierry.onkelinx at inbo.be > Havenlaan 88 bus 73, 1000 Brussel www.inbo.be > /////////////////////////////////////////////////////////////////////////////////////////// > To call in the statistician after the experiment is done > may be no more than asking him to perform a post-mortem > examination: he may be able to say what the experiment > died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote > is not data. ~ Roger Brinner The combination of some data > and an aching desire for an answer does not ensure that a > reasonable answer can be extracted from a given body of > data. ~ John Tukey > /////////////////////////////////////////////////////////////////////////////////////////// > <https://www.inbo.be> > [[alternative HTML version deleted]] > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Thierry Onkelinx
2018-Nov-21 10:30 UTC
[Rd] problematic dev.off() after running examples without plots
Dear Martin, Thanks for the feedback. After some more digging, I found that the problem was caused by a function which we imported from another package. That function closes open devices as a side-effect. Best regards, ir. Thierry Onkelinx Statisticus / Statistician Vlaamse Overheid / Government of Flanders INSTITUUT VOOR NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE AND FOREST Team Biometrie & Kwaliteitszorg / Team Biometrics & Quality Assurance thierry.onkelinx at inbo.be Havenlaan 88 bus 73, 1000 Brussel www.inbo.be /////////////////////////////////////////////////////////////////////////////////////////// To call in the statistician after the experiment is done may be no more than asking him to perform a post-mortem examination: he may be able to say what the experiment died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote is not data. ~ Roger Brinner The combination of some data and an aching desire for an answer does not ensure that a reasonable answer can be extracted from a given body of data. ~ John Tukey /////////////////////////////////////////////////////////////////////////////////////////// <https://www.inbo.be> Op wo 21 nov. 2018 om 10:47 schreef Martin Maechler < maechler at stat.math.ethz.ch>:> >>>>> Thierry Onkelinx via R-devel > >>>>> on Tue, 20 Nov 2018 14:16:20 +0100 writes: > > > Dear all, When running R CMD check on our package, we get > > an error on the examples. > > > Error in grDevices::dev.off() : > > cannot shut down device 1 (the null device) > > > None of the examples in our package generates > > plots. grDevices::dev.off() is code added by R CMD > > check. > > Yes, but there's also code added at the very beginning of the > examples R script ( <pkg>-Ex.R ) which opens a pdf device: > > grDevices::pdf.options(width = 7, height = 7, paper = "special", reset > TRUE) > grDevices::pdf(paste(pkgname, "-Ex.pdf", sep=""), encoding = "ISOLatin1") > > and so things should work and do work well for packages without any plots. > > You must be doing something particularly strange in some of *your* > examples such as closing all existing devices -- something you should not > do: > > As a good citizen you close graphic devices that you open but not others. > > > A workaround is to have at least one example which > > has some plot. Is there a better solution? > > Yes, find the example in your package which does the above > "strange thing" and modify that. > > Best, > Martin Maechler > ETH Zurich and R Core Team > > > > We are using R 3.5.1 > > > Best regards, > > > ir. Thierry Onkelinx Statisticus / Statistician > > > Vlaamse Overheid / Government of Flanders INSTITUUT VOOR > > NATUUR- EN BOSONDERZOEK / RESEARCH INSTITUTE FOR NATURE > > AND FOREST Team Biometrie & Kwaliteitszorg / Team > > Biometrics & Quality Assurance thierry.onkelinx at inbo.be > > Havenlaan 88 bus 73, 1000 Brussel www.inbo.be > > > > /////////////////////////////////////////////////////////////////////////////////////////// > > To call in the statistician after the experiment is done > > may be no more than asking him to perform a post-mortem > > examination: he may be able to say what the experiment > > died of. ~ Sir Ronald Aylmer Fisher The plural of anecdote > > is not data. ~ Roger Brinner The combination of some data > > and an aching desire for an answer does not ensure that a > > reasonable answer can be extracted from a given body of > > data. ~ John Tukey > > > /////////////////////////////////////////////////////////////////////////////////////////// > > > <https://www.inbo.be> > > > [[alternative HTML version deleted]] > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel >[[alternative HTML version deleted]]