[R-pkg-devel] [External] Re: Two packages with the same generic function

Viechtbauer, Wolfgang (SP) wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Tue Jun 23 16:28:59 CEST 2020


Still, if pkgA imports the generic from pkgB, then installing pkgA installs pkgB and all of its dependencies (Depends and Imports). Which of course makes sense (as otherwise pkgB cannot be installed). But all of this just for importing

foo <- function(x, ...)
   UseMethod("foo")

from pkgB.

Best,
Wolfgang

>-----Original Message-----
>From: R-package-devel [mailto:r-package-devel-bounces using r-project.org] On
>Behalf Of Duncan Murdoch
>Sent: Tuesday, 23 June, 2020 12:25
>To: Guido Schwarzer; r-package-devel using r-project.org
>Subject: Re: [R-pkg-devel] [External] Re: Two packages with the same generic
>function
>
>On 23/06/2020 4:22 a.m., Guido Schwarzer wrote:
>> Am 23.06.20 um 10:00 schrieb Viechtbauer, Wolfgang (SP):
>>> [...]
>>> @Neal: A separate package with generic functions that pkgA and pkgB could
>import is an interesting suggestion, thanks!
>>
>> What makes this interesting is that there is no dependency on other
>> packages in generics.
>>
>> Remains the question which help page would be shown for help(foo).
>
>If a package imports and then exports the generic, it would normally
>create a help page referring to the original one where the generic is
>defined.  So both pkgA and pkgB would probably both create help pages,
>and the help system would show a page listing them both plus the generic
>one, and asking the user to choose.
>
>An example happens if you use
>
>library(broom)
>?tidy
>
>The broom package links to a page that says "These objects are imported
>from other packages. Follow the links below to see their documentation."
>One of the links is to the ?tidy page in the generics package.
>
>You are allowed to say ?broom::tidy, and then you don't go to the list
>of possibilities, you go directly to the one you asked for.
>
>Duncan Murdoch



More information about the R-package-devel mailing list