Hi Michael,

It should be fine to have rgl in Suggests, and to have the 3D graphics functions that use rgl throw an error if rgl is absent. What's not fine is having these errors triggered in the absence of rgl when examples are run or vignettes are compiled.

Putting rgl into Depends rather than Suggests would make the problem worse, because you couldn't then load your package without rgl.

So, as I believe a couple of others have suggested, wrap the problematic examples in, e.g., if(requireNamespace("rgl")){}, and do something similar in the vignettes.

I hope this helps,
 John

John Fox, Professor Emeritus
McMaster University
Hamilton, Ontario, Canada
web: https://socialsciences.mcmaster.ca/jfox/

On 2020-12-12 1:40 p.m., Michael L Friendly wrote:
Thanks, Dirk

Just to clarify--
In my packages, candisc, heplots, vcdExtra I have mostly 2D graphic methods, 
but some 3D methods that use
rgl.  I therefore put rgl into Suggests:

Could I solve this by making rgl a Depends: ?

-Michael


-----Original Message-----
From: Dirk Eddelbuettel <e...@debian.org>
Sent: Saturday, December 12, 2020 12:46 PM
To: Michael L Friendly <frien...@yorku.ca>
Cc: r-package-devel@R-project.org; Prof Brian Ripley <rip...@stats.ox.ac.uk>
Subject: Re: [R-pkg-devel] CRAN packages suggesting other packages but not 
using them conditionally


On 12 December 2020 at 16:24, Michael L Friendly wrote:
| I got the email below concerning 3 of my packages but wonder if they
| are false alarms or if not, how to locate & fix the problem.
|
|     This concerns packages: ...
|
|     Suggested packages should be used conditionally: see  1.1.3.1 of 'Writing 
R Extensions'.  Some of these are hard to install on a platform without X11 
such as M1 Macs: see the logs at https://www.stats.ox.ac.uk/pub/bdr/M1mac/.
|
|     You can check all of the suggested packages by setting environment 
variable _R_CHECK_DEPENDS_ONLY_=true  -- see 
https://cran.r-project.org/doc/manuals/r-devel/R-ints.html#Tools .
|
| Is this a false alarm?
|
| In each case, the outfile contains:
|
|     * checking package namespace information ... OK
|     * checking package dependencies ... NOTE
|     Package suggested but not available for checking: 'rgl'
|
| indicating that rgl is not avaiable on the testing machine.  Then,
| when checking examples an error is triggered when an example calls something 
that requires rgl.
|
|     >
|     > heplot3d(Adopted.mod, hypotheses=list("Reg"=c("AMED", "BMIQ")),
|     +         col = c("red", "blue", "black", "gray"), wire=FALSE)
|     Loading required namespace: rgl
|     Failed with error:  'there is no package called 'rgl''
|     Error in heplot3d.mlm(Adopted.mod, hypotheses = list(Reg = c("AMED", 
"BMIQ")),  :
|       rgl package is required.
|     Calls: heplot3d -> heplot3d.mlm
|     Execution halted
|
| Yet, heplot3d seems to contain the required way to refer to the suggested rgl 
package:
|
|                 if (!requireNamespace("rgl")) stop("rgl package is
| required.")
|
| So, I'm mystified.  Can anyone help?

This is not conditional use in the sense of my reading of WRE.

What you have here is essentially an "assert()" and equivalent to
   stopifnot(requireNamespace("rgl"))
which, in turn, is equivalent to a strong Depends or Imports as your package 
will experience a _critical error_ triggered by `stop()` if rgl is missing.

The idea of a conditional use is to, well, be conditional. Below I make use of 
Rcpp if is present, but it is only a suggests:

   ## see the source files in the snippets/ directory of the package
   ## check for (optional, only in Suggests:) Rcpp, and also wrapped in a
   ## dontrun as it takes 10s at CRAN (yet only 3.5 here) yielding a NOTE
   if (requireNamespace("Rcpp", quietly=TRUE)) {
       Rcpp::sourceCpp(system.file("snippets", "convolveExample.cpp", 
package="tidyCpp"))
   }

If the _suggested_ package is present, it is used. If not we quietly move on.
(It's not the full story as the compilation occassionally takes longer, Windows 
complained so all this is now in a \dontrun{} block too. But the idea is 
generic and there are many more examples to be found.)

Hope this helps,  Dirk

--
https://dirk.eddelbuettel.com | @eddelbuettel | e...@debian.org
______________________________________________
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

Reply via email to