[R-pkg-devel] Calls not declared

Jeff Newmiller jdnewm|| @end|ng |rom dcn@d@v|@@c@@u@
Mon Mar 11 19:12:58 CET 2019


Ah, so as long as you don't need to call a normal function to make use of the returned object you don't need Depends. But in this example, the user would then need to call library(ggplot2) in order to, say, change an axis title.

A bit more subtle than I thought.

On March 11, 2019 10:07:12 AM PDT, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
>On 11/03/2019 11:32 a.m., Jeff Newmiller wrote:
>> I did not see any mention of the distinction between Depends and
>Imports in the DESCRIPTION file... which is always a risk when
>duplicating existing documentation in an email. Imports is preferred
>because the user does not have to put definitions only needed inside
>your package into their public search path (easier to make
>under-the-hood changes to the package implementation), but Depends is
>better when they cannot make use of your package without those
>definitions (e.g. you return a ggplot object from one of your
>functions).
>> 
>
>You don't need Depends to be able to handle ggplot2 objects. You'll get
>
>the methods when the package is loaded, so they'll print fine without 
>having ggplot2 on the search list.
>
>There are very few cases nowadays where it makes sense to use Depends.
>
>Duncan Murdoch
>
>> So do keep reading the documentation... email is just a kickstart.
>> 
>> On March 11, 2019 8:19:33 AM PDT, Duncan Murdoch
><murdoch.duncan using gmail.com> wrote:
>>> 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
>>>
>>> ______________________________________________
>>> R-package-devel using r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> 

-- 
Sent from my phone. Please excuse my brevity.



More information about the R-package-devel mailing list