[R-pkg-devel] Building my R package: issue when importing two functions with the same name

Rainer M Krug R@iner @ending from krug@@de
Tue Aug 7 13:23:04 CEST 2018


This is very useful - didn’t know that.

Thanks

Rainer


> On 7 Aug 2018, at 13:11, Duncan Murdoch <murdoch.duncan using gmail.com> wrote:
> 
> On 05/08/2018 4:21 PM, Gianmarco Alberti wrote:
>> I am building a R package, and I am facing an issue caused (as far as I understand) by the fact that some functions out of my package rely on two fuctions having the same name and coming from 2 different packages:
>> pROC::roc
>> spatstat::roc
> 
> As Iñaki pointed out, the main issue is that you should be using Import rather than Depends.  But I didn't see mentioned the fact that the NAMESPACE file can rename a function when you import it, e.g.
> 
> importFrom(pROC, pROCroc = roc)
> importFrom(spatstat, spatstatroc = roc)
> 
> Now in your own functions you can use pROCroc() or spatstatroc() and they won't conflict.
> 
> (I was going to point you to the documentation for this, but I am not sure it is properly documented anywhere.)
> 
> Duncan Murdoch
> 
>> When checking the package via devtools::check(), I get the following warning:
>> Warning: replacing previous import ‘spatstat::roc’ by ‘pROC::roc’ when loading ‘GmAMisc’
>> Note that both packages are listed among the Imports in my package's DESCRIPTION file, and that (within my functions) I have actually used spatstat::roc and pROC::roc where needed.
>> I have done some web-search but I could not locate any workaround that actually fixes my issue.
>> Do you have any suggestion on the matter?
>> **************************************
>> Dr Gianmarco Alberti (PhD)
>> (currently)
>> Research Support Officer II
>> Department of Classics and Archaeology
>> Faculty of Arts
>> University of Malta
>> (starting from 3rd September 2018)
>> Lecturer in Spatial Forensics
>> Department of Criminology
>> Faculty for Social Wellbeing
>> University of Malta
>> https://www.researchgate.net/profile/Gianmarco_Alberti4
>> http://cainarchaeology.weebly.com/
>> **************************************
>> 	[[alternative HTML version deleted]]
>> ______________________________________________
>> R-package-devel using r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> 
> 
> ______________________________________________
> R-package-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

--
Rainer M. Krug, PhD (Conservation Ecology, SUN), MSc (Conservation Biology, UCT), Dipl. Phys. (Germany)

University of Zürich

Cell:       +41 (0)78 630 66 57
email:      Rainer using krugs.de
Skype:      RMkrug

PGP: 0x0F52F982




-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: Message signed with OpenPGP
URL: <https://stat.ethz.ch/pipermail/r-package-devel/attachments/20180807/5bbbd2f7/attachment.sig>


More information about the R-package-devel mailing list