[R-pkg-devel] Explicitly Calling a Method of a specific Class in a Function

Dirk Eddelbuettel edd @ending from debi@n@org
Mon May 7 13:44:28 CEST 2018


On 6 May 2018 at 11:42, Dr. rer. nat. Michael Thrun wrote:
| Dear Developers,
| I have currently one note in one of my packages I am unable to solve at my own:
|| checking dependencies in R code ... NOTE
| Unexported object imported by a ':::' call: ‘sp:::plot.SpatialPolygons’
|   See the note in ?`:::` about the use of this operator.
|| The goal is to explicitly call the plot function of the 'SpatialPolygons-class' in the function ‘plotWorldmap'.
| In The CRAN checks the examples work. Manual calling 
| of the function ‘plotWorldmap' also works in an clean environment yielding the expected plot.
| Thus, I assume the call
|  sp:::plot.SpatialPolygons(world_country_polygons,col =cols,…)
| is in principle correct. 
| 
| Could someone please help me?
| What do I have to do or to change in order to disable this note?

You are not supposed to 'silently' call code from other package without
declaring the dependency on that package.

So add an 'imports(sp)', or maybe 'importFrom(sp, plot.SpatialPolygons)' to
you NAMESPACE file, and add Imports: sp to your DESCRIPTION.

Also, either sp exports plot.SpatialPolygons() already so that you can just
two dots as you should for exported functions, or maybe just use method based
dispatch via plot() -- or sp does not export the function in which case you
should not call it.

Dirk

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org



More information about the R-package-devel mailing list