[R-pkg-devel] Should 'methods' be in Imports?
Duncan Murdoch
murdoch@dunc@n @end|ng |rom gm@||@com
Thu Mar 16 19:43:04 CET 2023
On 16/03/2023 2:21 p.m., Noah Greifer wrote:
>
> Thank you for your input. /broom/, /mlogit/, /twang/, and /Hmisc/
> are examples of major packages that import functions from /stats/,
> /utils/, /graphics/, or other base packages but don't include them in
> the DESCRIPTION. All of my packages (/cobalt/, /WeightIt/, /MatchIt/) do
> too, and I have never had a message from CRAN about it. (None of these
> are specifically about /methods/, but as a base package I assume it
> should work the same as these others.)
>
broom doesn't mention stats in DESCRIPTION, but does import from it in
the NAMESPACE. (I haven't checked the rest of your list.) I'm a little
surprised by that, but it's understandable: the NAMESPACE does declare
that stats is needed. WRE says this about Imports:
"Namespaces accessed by the ‘::’ and ‘:::’ operators must be listed
here, or in ‘Suggests’ or ‘Enhances’ (see below). Ideally this field
will include all the standard packages that are used, and it is
important to include S4-using packages."
So the use of Imports for "standard packages" that are used in NAMESPACE
appears to be optional but recommended.
However, my understanding was that you were talking about using things
like graphics::abline without importing any graphics functions via the
NAMESPACE; in that case, the manual is very explicit that you would need
to put graphics in Imports. That doesn't mean "R CMD check" will
complain if you don't, but it does mean that it might start doing so if
it doesn't already.
Do you know of any examples of packages that use things like
graphics::abline without mentioning graphics in either the NAMESPACE or
DESCRIPTION file?
Duncan Murdoch
More information about the R-package-devel
mailing list