[R-pkg-devel] Calls not declared
On 11/03/2019 2:12 p.m., Jeff Newmiller wrote:
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.
I think the current philosophy is that if a user wants to be able to use
ggplot2 functions, the user should ask for them, they shouldn't be
automagically added to the search list. If a user wants to change the
axis title and doesn't want to have ggplot2 on their search list, that
is definitely possible:
ggplot2::qplot(1:10, 1:10) + ggplot2::xlab("new x label")
Duncan Murdoch
A bit more subtle than I thought. On March 11, 2019 10:07:12 AM PDT, Duncan Murdoch <murdoch.duncan at 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 at 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 at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-package-devel