[Rcpp-devel] Package RMD check warning

Dirk Eddelbuettel edd at debian.org
Mon Jan 30 19:45:55 CET 2023


On 30 January 2023 at 18:11, Zheng, Binghan wrote:
| I’m preparing a package to be released through CRAN for Dr. Jacob Montgomery at WUSTL and I’m running into a warning that I can’t seem to resolve.
| 
| The RCMD check is being run in R 4.2.2 on MacOS.
| After running devtools::check() on the labelR package, it returns this warning:

I personally (and strongly) prefer the clarity of the R CMD ... commands over
the combination of obfuscations and convenience offered by other wrappers
(but yes I understand they are convenient and powerful--but harder to
debug). I would recommend you try to solve this with base commands.

|  checking dependencies in R code ... WARNING
|   'loadNamespace' or 'requireNamespace' call not declared from: ‘Rcpp’
|   Package in Depends field not imported from: ‘methods’

It's a guess as we cannot see your sources (if there is a GitHub (or alike)
repo, always post a link!) but I suspect you have a Depends: Rcpp when you
should have an Imports: Rcpp *and* also a standard line in NAMESPACE such as

   importFrom(Rcpp,evalCpp)

(where it doesn't matter _which_ function you tag, what matters is that the
package get imported at startup which intializes a few things that are
needed).  You need both.

|     These packages need to be imported from (in the NAMESPACE file)
|     for when this namespace is loaded but not attached.
| 
| @imports ‘Rcpp’ has been included in all relevant functions

You need  "@importFrom Rcpp sourceCpp"  to create the line above.  Again,
roxygen2 obfuscates here. I always documented it as 'better by hand'.

| It is currently in the scripts as requireNamespace(“Rcpp”) since we are using requireNamespace(“rstan”). We have tried loadNamespace(“Rcpp”) which did not resolve the issue.
| Imports(‘Rcpp’) is within NAMESPACE.
| Within the DESCRIPTION file, Rcpp is under Imports. We have tried moving it to Suggests, but that also did not resolve the issue. It’s unclear what the error is stemming from and we would appreciate any input to resolve this warning.

If in doubt, also try to look at a working package. For Rcpp you now have
well over 2600 to choose from at CRAN :)  As well as working package creators
that provide this.  You can always start from an empty package that you can
grow to contain your content.

Best, Dirk

-- 
dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list