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

2020-07-22 Thread Helmut Schütz

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)) {
  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

--
Ing. Helmut Schütz
BEBAC – Consultancy Services for
Bioequivalence and Bioavailability Studies
Neubaugasse 36/11
1070 Vienna, Austria
W https://bebac.at/
F https://forum.bebac.at/

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Serguei Sokol

Le 22/07/2020 à 14:36, Helmut Schütz a écrit :

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)) {
   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.
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;
 - or the error comes from some other place of the code.

Sorry but without a minimal reproducible example I cannot help more.
Best,
Serguei.

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Jeff Newmiller
I suspect your foo and bar variables are not logical anymore... insufficient 
info. However, why aren't you using short-circuit && and || operators?

On July 22, 2020 5:36:06 AM PDT, "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)) {
>   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

-- 
Sent from my phone. Please excuse my brevity.

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Duncan Murdoch

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



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Helmut Schütz

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()
}

Best,
Helmut

--
Ing. Helmut Schütz
BEBAC – Consultancy Services for
Bioequivalence and Bioavailability Studies
Neubaugasse 36/11
1070 Vienna, Austria
T +43 1 2311746
M +43 699 10792458
E helmut.schu...@bebac.at
W https://bebac.at/
C https://bebac.at/Contact.htm
F https://forum.bebac.at/
GIS 24799386, VAT ATU61115625, DUNS 300370568, EORI ATEOS196209
GDPR https://bebac.at/Data-Protection.htm

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Duncan Murdoch

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

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] import 'as' from another package

2020-07-22 Thread Sebastian Meyer
Following WRE 1.5.6 (Namespaces with S4 classes and methods), you should
have "Depends: methods" in your DESCRIPTION, and "import(methods)" or a
more selective "importFrom(methods, ...)" directive in your NAMESPACE.

Then you would usually use the NAMESPACE directive

importMethodsFrom(package, generic)

to explicitly import S4 methods exported from another package.
However, the raster package does not do

exportMethods(coerce)

so if you try

importMethodsFrom(raster, coerce)

you will get

> Error: object ‘coerce’ is not exported by 'namespace:raster'

when trying to install your package (also during R CMD check, of course).

To solve this problem, you could either

- import raster's entire NAMESPACE via import(raster)

- or ask maintainer("raster") to exportMethods(coerce)

- or do

importClassesFrom(raster, RasterLayer)

which will magically make the corresponding coerce methods available as
well.

HTH!

Sebastian Meyer


Am 21.07.20 um 00:41 schrieb Tim Keitt:
> Thanks for pointing to the bug.
> 
> Now I am finding I cannot use the 'as' definitions from 'raster' without
> loading the package. Do I need an @import directive that specifies the
> definitions in the 'raster' package? My understanding is that the
> 'setAs' function generates a 'coerce,...' signature but I'm not sure how
> to import it to my package.
> 
> Thanks again.
> 
> THK
> 
> On Mon, Jul 20, 2020 at 2:25 PM Sebastian Meyer  > wrote:
> 
> Yes, indeed, it is confusing. You don't need to file a new bug
> report, though. There is one already:
> 
> https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17179
> 
> Please feel free to comment there. This thread could serve as
> another confirmation. :-)
> 
> Best regards,
> Sebastian
> 
> Am 20. Juli 2020 18:36:21 MESZ schrieb Ben Bolker  >:
> >    I think this is a classic confusing R message.  Try adding methods
> >to the Imports: statement in your DESCRIPTION file and see if that
> >helps. (Maybe I should file a bug report about that error message - it
> >confuses me every time.)
> >
> >On 7/20/20 12:34 PM, Tim Keitt wrote:
> >> It works but "check" gives
> >>
> >> > checking package dependencies ... ERROR
> >>   Namespace dependency not required: ‘methods’
> >>
> >> THK
> >>
> >> On Mon, Jul 20, 2020 at 11:24 AM Ben Bolker  
> >> >> wrote:
> >>
> >>     @importFrom methods as
> >>
> >>     ?
> >>
> >>     On 7/20/20 12:06 PM, Tim Keitt wrote:
> >>     > I have
> >>     >
> >>     >    if (!inherits(x, "RasterLayer")) x <- as(x, "RasterLayer")
> >>     >
> >>     > in a package and its not finding the coerce definition from the
> >>     raster
> >>     > package. I know I need to add an @import roxygen2 directive of
> >>     some kind,
> >>     > but I'm not sure the correct syntax. My first try generated a
> >>     warning that
> >>     > it was not needed.
> >>     >
> >>     > What is the correct way to do this? Or does raster need to
> >>     export this
> >>     > definition?
> >>     >
> >>     > THK
> >>     >
> >>     >       [[alternative HTML version deleted]]
> >>     >
> >>     > __
> >>     > R-package-devel@r-project.org
> 
> >>      > mailing list
> >>     > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >>     __
> >>     R-package-devel@r-project.org
> 
> >>      > mailing list
> >>     https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >>
> >
> >       [[alternative HTML version deleted]]
> >
> >__
> >R-package-devel@r-project.org
>  mailing list
> >https://stat.ethz.ch/mailman/listinfo/r-package-devel
>

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Helmut Schütz



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.schu...@bebac.at
W https://bebac.at/
F https://forum.bebac.at/


[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2020-07-22 Thread Duncan Murdoch

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.schu...@bebac.at
Whttps://bebac.at/
Fhttps://forum.bebac.at/



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


[R-pkg-devel] inappropriate maintainer moniker

2020-07-22 Thread brian knaus
Hello R-pkg-devel,

Our package vcfR,

https://github.com/knausb/vcfR

has been removed from CRAN because they asked me to make changes that I
have not been able to make before their deadline. One of the issues was
that the moniker

"briank.lists"

is not appropriate and that we should see CRAN policy. I interpret "CRAN
policy" here to be the following link.

https://cran.r-project.org/web/packages/policies.html

I'm struggling with *why* is this inappropriate, so I do not understand how
to fix it. My attempt to interpret this issue is that this "moniker" has
been interpreted as a "mailing list" by a CRAN member. The policy states
that a "single designated maintainer (a person, not a mailing list)" should
be included in the DESCRIPTION. However, in vcfR this address is a "single
designated maintainer" (me). It's where I receive mail from various mailing
lists I've signed up for. For example, mail I receive from "R-pkg-devel"
comes to this address. So I feel that this is confusion on the side of
CRAN. Does anyone see a reason for *why* this may be considered
inappropriate?

Thank you!
Brian Knaus

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


Re: [R-pkg-devel] inappropriate maintainer moniker

2020-07-22 Thread Ben Bolker
    Once all the other issues are resolved, I'd suggest e-mailing 
r-cran-submissions with this explanation and asking for clarification.


    My interpretation would have been the same as yours (i.e., that 
this is an appropriate e-mail address, and that CRAN maintainers may 
have misinterpreted it a mailing list address).


On 7/22/20 7:05 PM, brian knaus wrote:

Hello R-pkg-devel,

Our package vcfR,

https://github.com/knausb/vcfR

has been removed from CRAN because they asked me to make changes that I
have not been able to make before their deadline. One of the issues was
that the moniker

"briank.lists"

is not appropriate and that we should see CRAN policy. I interpret "CRAN
policy" here to be the following link.

https://cran.r-project.org/web/packages/policies.html

I'm struggling with *why* is this inappropriate, so I do not understand how
to fix it. My attempt to interpret this issue is that this "moniker" has
been interpreted as a "mailing list" by a CRAN member. The policy states
that a "single designated maintainer (a person, not a mailing list)" should
be included in the DESCRIPTION. However, in vcfR this address is a "single
designated maintainer" (me). It's where I receive mail from various mailing
lists I've signed up for. For example, mail I receive from "R-pkg-devel"
comes to this address. So I feel that this is confusion on the side of
CRAN. Does anyone see a reason for *why* this may be considered
inappropriate?

Thank you!
Brian Knaus

[[alternative HTML version deleted]]

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel