[R-pkg-devel] two functions with the same name when importing

Bernd.Gruber Bernd@Gruber @end|ng |rom c@nberr@@edu@@u
Thu Nov 7 10:51:21 CET 2019


@Martin Morgan<mailto:mtmorgan.bioc using gmail.com>

Thanks to your hint if found this:

@rawNamespace import(adegenet, except = plot)

which works beautifully  and no need to go through each Namespace function.

Thanks again to everyone.




From: Martin Morgan <mtmorgan.bioc using gmail.com>
Sent: Thursday, 7 November 2019 8:34 PM
To: Duncan Murdoch <murdoch.duncan using gmail.com>; Bernd.Gruber <Bernd.Gruber using canberra.edu.au>; r-package-devel using r-project.org
Subject: Re: [R-pkg-devel] two functions with the same name when importing

RShowDoc("R-exts") setion 1.5.1 Specifying imports and exports indicates that imports() has an except= argument, so

import(adegenet, except = plot)

might do the trick. Use it in your package as `adegenet::plot()`.

Martin Morgan

On 11/6/19, 8:31 PM, "R-package-devel on behalf of Duncan Murdoch" <r-package-devel-bounces using r-project.org on behalf of murdoch.duncan using gmail.com<mailto:r-package-devel-bounces using r-project.org%20on%20behalf%20of%20murdoch.duncan using gmail.com>> wrote:

On 06/11/2019 6:50 p.m., Bernd.Gruber wrote:
> Hi,
>
> I have a problem regarding the name of two functions and I know the "correct" way is to use importFrom to make sure only specified functions are imported. But my problem is that my package really depends on another package
> adegenet as I basically use 90% of the say >100 functions.
>
> So when I import all of adegenet I get:
>
> 2: replacing previous import 'adegenet::plot' by 'graphics::plot' when loading 'dartR'
>
>
> So in essence I think adegenet is importing a plot function which collides with the basic plot function. Is there anything I can do, without going through 100 functions and using importFrom
>
> In addition I actually need the plot function from adegenet, so I would need to rename it as well somehow.
>
> Any hint how to solve this would be highly appreciated.

Just get a copy of the adegenet NAMESPACE file to get all of its
exports. Edit the list down to the ones you use, and use a text editor
to change the export directives to importFrom directives. It's not
really that hard.

The path to the NAMESPACE file is given by

system.file("NAMESPACE", package="adegenet")

Duncan Murdoch

______________________________________________
R-package-devel using r-project.org<mailto:R-package-devel using r-project.org> mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel<https://stat.ethz.ch/mailman/listinfo/r-package-devel>

	[[alternative HTML version deleted]]



More information about the R-package-devel mailing list