[R-pkg-devel] Calls not declared

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Mon Mar 11 16:19:33 CET 2019


On 11/03/2019 9:53 a.m., Elias Carvalho wrote:
> I am developing my first package and found these errors when checking it.
> 
> Any help?
> 
> 
> * checking dependencies in R code ... WARNING
> 'library' or 'require' calls not declared from:
>    ‘qgraph’ ‘semPlot’ ‘sna’ ‘xlsx’

Without seeing your package I might be wrong, but I believe this says 
that you have something like

library(qgraph)

somewhere in your R code, without listing

Depends: qgraph

in your DESCRIPTION file.

HOWEVER, fixing this warning will lead to a different one, because 
that's not the recommended way to do things now.  There are two 
possibilities:

1.  Your package is useless without the dependency.

In this case, you should put

Imports:  qgraph, ...

in the DESCRIPTION file (where ... lists the other packages with the 
same status), and list the functions in those packages in your NAMESPACE 
file, using

importFrom(qgraph, ...)

etc.  (If you use Roxygen, you use comments in the source to get it to 
put this into your NAMESPACE file.)

2.  Your package works without the dependency, but you may want to issue 
errors or warnings if it is missing.

Then you should put

Suggests:  qgraph, ...

in the DESCRIPTION file, and to use a function from it, use something like

if (requireNamespace("qgraph")) {
   qgraph::foo(...)
} else
   warning("qgraph is not available.")

Duncan Murdoch



More information about the R-package-devel mailing list