odd NOTE in R CMD check of data; Rcpp module related

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

odd NOTE in R CMD check of data; Rcpp module related

Robert J. Hijmans
With the current version of the "raster" package (that I maintain), R CMD
check on packages "soilDB" and "PopGenReport" have this NOTE:

Package: soilDB
Check: data for non-ASCII characters
New result: NOTE
    Error in .requirePackage(package) :
      unable to find required package 'raster'
    Calls: <Anonymous> ... .findInheritedMethods -> getClass -> getClassDef
-> .requirePackage
    Execution halted


In soiDB this is presumably triggered by loading this file:

> f <- system.file("data/gSSURGO.chunk.rda", package="soilDB")
> "raster" %in% .packages()
[1] FALSE
> load(f)
> gSSURGO.chunk
Loading required package: raster
Loading required package: sp
Error: package or namespace load failed for ‘raster’ in
.doLoadActions(where, attach):
 error in load action .__A__.1 for package raster: loadModule(module =
"spmod", what = TRUE, env = ns, loadNow = TRUE): Unable to load module
"spmod": object of type 'closure' is not subsettable
Error in .requirePackage(package) :
  unable to find required package ‘raster’

# but all is OK the second time around

> gSSURGO.chunk
class       : RasterLayer
dimensions  : 106, 137, 14522  (nrow, ncol, ncell)
resolution  : 4, 4  (x, y)

The error message suggests that something goes wrong with the Rcpp module
that raster is using. The module was newly introduced, and coincides with
this new behavior. Do you have any idea about what I could do to avoid this?

This behavior can be simply simulated by creating a new RasterLayer, saving
it, and loading it in a fresh session.

library(raster)
x <- raster(ncol=10, nrow=10, vals=1:100)
saveRDS(x, "x.rds")
--- new R session ---
readRDS("x.rds")
readRDS("x.rds")

This gives

> readRDS("x.rds")
Loading required package: raster
Loading required package: sp
Error: package or namespace load failed for ‘raster’ in
.doLoadActions(where, attach):
 error in load action .__A__.1 for package raster: loadModule(module =
"spmod", what = TRUE, env = ns, loadNow = TRUE): Unable to load module
"spmod": object of type 'closure' is not subsettable
Error in .requirePackage(package) :
  unable to find required package ‘raster’

> readRDS("x.rds")
class       : RasterLayer
dimensions  : 10, 10, 100  (nrow, ncol, ncell)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : +proj=longlat +datum=WGS84 +ellps=WGS84 +towgs84=0,0,0
data source : in memory
names       : layer
values      : 1, 100  (min, max)

Any idea about what I can do to get rid of this?

Thanks,
Robert Hijmans

        [[alternative HTML version deleted]]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: odd NOTE in R CMD check of data; Rcpp module related

Dirk Eddelbuettel

Robert,

On 3 November 2018 at 10:29, Robert J. Hijmans wrote:
| With the current version of the "raster" package (that I maintain), R CMD
| check on packages "soilDB" and "PopGenReport" have this NOTE:
|
| Package: soilDB
| Check: data for non-ASCII characters
| New result: NOTE
|     Error in .requirePackage(package) :
|       unable to find required package 'raster'
|     Calls: <Anonymous> ... .findInheritedMethods -> getClass -> getClassDef
| -> .requirePackage
|     Execution halted

[...]

| Any idea about what I can do to get rid of this?

Shooting a little from the hip, but based on the error and a glance at

  https://github.com/ncss-tech/soilDB/blob/master/DESCRIPTION

you may need to import the 'methods' package.  I see that

  https://github.com/green-striped-gecko/PopGenReport/blob/master/DESCRIPTION

has it (and also a corresponding `importFrom(methods,as)`.  I think I usually
deploy a more global 'import(methods)'.  This is needed because Rcpp Modules
does some black magic on the package setup to make everything that needs to
be visible effectively visible.

One way to go about this is to create a minimal package using Rcpp Modules,
and to then make sure you carry each setting of the minimal package over into
your actual package -- that would usually involve imports and declaration.

Dirk

--
http://dirk.eddelbuettel.com | @eddelbuettel | [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel