[R-pkg-devel] NAMESPACE issue and grDevices

Kevin Coombes kev|n@r@coombe@ @end|ng |rom gm@||@com
Sat Aug 24 16:36:44 CEST 2019


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



More information about the R-package-devel mailing list