[R-pkg-devel] NAMESPACE issue and grDevices

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Sat Aug 24 19:03:40 CEST 2019


I think yes. If a direct user of graphics opted not to call smoothScatter then they would have no need to even install KernSmooth. However, since generics automatically trigger loading of class-specific methods, one of which in your case includes that dependency, your package cannot avoid at least importing KernSmooth.

On August 24, 2019 7:36:44 AM PDT, Kevin Coombes <kevin.r.coombes using gmail.com> wrote:
>Hi,
>
>I've been building a package and hit a NAMESPACE issue that took a
>while 
>to resolve.
>
>My package implements a (new) generic function, and the method for a 
>package in the class calls the "smoothScatter" function from the 
>"graphics" package. I could build and install the package successfully,
>
>and when I used the generic function, it worked just fine.
>
>However, when I ran "R CMD check --as-cran", it threw an error from
>both 
>the examples in man pages and a test script. Specifically, the error
>was 
>"package KernSmooth not available". I eventually worked around this 
>problem by changing the DESCRIPTION file to "IMPORT KernSmooth" (even 
>though I didn't have to actually import anything in "NAMESPACE").
>
>The underlying issue appears to be that
>     graphics::smoothScatter
>calls a non-exported function from "grDevices"
>      grDevices:::.smoothScatterCalcDensity
>which in turn calls an explicitly qualified function from "KernSmooth"
>     KernSmooth::bkde2D
>
>To complicate matters
>     graphics IMPORTs grDevices
>but
>     grDevices only SUGGESTs KernSmooth.
>
>Since my package already IMPORTed the graphics package and had
>     importFrom("graphics", "smoothScatter")
>in the NAMESPACE, I was surprised that I had to track back through the 
>code to find this dependency and had to make it explicitly known within
>
>the interface to my package.
>
>Is there something else my package should do? Or should "grDevices" 
>actually IMPORT "KernSmooth"?
>
>Best,
>   Kevin
>
>______________________________________________
>R-package-devel using r-project.org mailing list
>https://stat.ethz.ch/mailman/listinfo/r-package-devel

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



More information about the R-package-devel mailing list