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

2018-08-07 Thread Gianmarco Alberti
@Duncan:

Extremely interesting...thanks.

Gm


**
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/
**

Il 7 ago 2018, 13:11 +0200, Duncan Murdoch , ha 
scritto:
> 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@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
>
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Duncan Murdoch

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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Gianmarco Alberti
Thanks indeed for the clarification.

I eventually managed to solve the issue. By the way, I have moved of the 
packages my package relies on to the Imports section.
I have checked my package and it returned no error nor note nor warning.
I have submitted it to CRAN.

Thanks for your prompt feedback.

Best
Gm A


**
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/
**

Il 7 ago 2018, 11:14 +0200, Uwe Ligges , ha 
scritto:
> ... and even if you are importing from several packages, you should
> import selective via importFrom directoves.
>
> If you need two functions with identical names, import at most one of
> them and rather use pkg::foo syntax to access them.
>
> Best,
> Uwe Ligges
>
>
>
>
>
> On 07.08.2018 10:14, Iñaki Úcar wrote:
> > El mar., 7 ago. 2018 a las 9:32, Gianmarco Alberti
> > () escribió:
> > >
> > > 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
> > >
> > > 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 see:
> >
> > Depends: R (>= 3.4.0), ggplot2, ggrepel, rgdal, rgeos, raster, sp,
> > spatstat, maptools, spatialEco, dismo, pROC, kimisc, corrplot,
> > InPosition, lsr, gridExtra, caTools, plyr, classInt, coin, DescTools,
> > rWind, shape, rworldmap, cluster, RcmdrMisc, gdistance, Hmisc
> >
> > In general, it is not a good idea to depend on so many packages,
> > because what "Depends" do is to load and attach packages. Among other
> > issues, there is one that you are already experimenting: "roc" is
> > exported both by "spatstat" and "pROC", so one masks the other.
> >
> > The solution is to list them under "Imports" instead of "Depends". In
> > fact, my advice is to put as many packages as possible under
> > "Imports". Keep in "Depends" only those you would load and attach
> > anyway when working with your package, because you need all the
> > functions along with the ones your package exports. For the rest of
> > them, just use them as package::function to avoid this kind of
> > problem, and reexport functions selectively if needed.
> >
> > Iñaki
> >
> > PS: I'm taking a look at other packages and I see that you always use
> > "Depends" and never "Imports". My general advice is against this
> > practice. Moreover, from the "Writing R Extensions" manual:
> >
> > "Field ‘Depends’ should nowadays be used rarely, only for packages
> > which are intended to be put on the search path to make their
> > facilities available to the end user (and not to the package itself):
> > for example it makes sense that a user of package 'latticeExtra' would
> > want the functions of package 'lattice' made available."
> >
> > >
> > > 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@r-project.org mailing list
> > > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
> > __
> > R-package-devel@r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-package-devel
> >
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Rainer M Krug
Probably discussed already, but what is the difference between using “::” and 
“ImportFrom”? I usually use ImportFrom and “::” just to make clear, where the 
function is coming from - is this a problem?

Rainer


> On 7 Aug 2018, at 11:14, Uwe Ligges  wrote:
> 
> ... and even if you are importing from several packages, you should import 
> selective via importFrom directoves.
> 
> If you need two functions with identical names, import at most one of them 
> and rather use pkg::foo syntax to access them.
> 
> Best,
> Uwe Ligges
> 
> 
> 
> 
> 
> On 07.08.2018 10:14, Iñaki Úcar wrote:
>> El mar., 7 ago. 2018 a las 9:32, Gianmarco Alberti
>> () escribió:
>>> 
>>> 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
>>> 
>>> 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 see:
>> Depends: R (>= 3.4.0), ggplot2, ggrepel, rgdal, rgeos, raster, sp,
>> spatstat, maptools, spatialEco, dismo, pROC, kimisc, corrplot,
>> InPosition, lsr, gridExtra, caTools, plyr, classInt, coin, DescTools,
>> rWind, shape, rworldmap, cluster, RcmdrMisc, gdistance, Hmisc
>> In general, it is not a good idea to depend on so many packages,
>> because what "Depends" do is to load and attach packages. Among other
>> issues, there is one that you are already experimenting: "roc" is
>> exported both by "spatstat" and "pROC", so one masks the other.
>> The solution is to list them under "Imports" instead of "Depends". In
>> fact, my advice is to put as many packages as possible under
>> "Imports". Keep in "Depends" only those you would load and attach
>> anyway when working with your package, because you need all the
>> functions along with the ones your package exports. For the rest of
>> them, just use them as package::function to avoid this kind of
>> problem, and reexport functions selectively if needed.
>> Iñaki
>> PS: I'm taking a look at other packages and I see that you always use
>> "Depends" and never "Imports". My general advice is against this
>> practice. Moreover, from the "Writing R Extensions" manual:
>> "Field ‘Depends’ should nowadays be used rarely, only for packages
>> which are intended to be put on the search path to make their
>> facilities available to the end user (and not to the package itself):
>> for example it makes sense that a user of package 'latticeExtra' would
>> want the functions of package 'lattice' made available."
>>> 
>>> 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@r-project.org mailing list
>>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> __
>> R-package-devel@r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-package-devel
>> 
> 
> __
> R-package-devel@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:  rai...@krugs.de
Skype:  RMkrug

PGP: 0x0F52F982





signature.asc
Description: Message signed with OpenPGP
__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Uwe Ligges
... and even if you are importing from several packages, you should 
import selective via importFrom directoves.


If you need two functions with identical names, import at most one of 
them and rather use pkg::foo syntax to access them.


Best,
Uwe Ligges





On 07.08.2018 10:14, Iñaki Úcar wrote:

El mar., 7 ago. 2018 a las 9:32, Gianmarco Alberti
() escribió:


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

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 see:

Depends: R (>= 3.4.0), ggplot2, ggrepel, rgdal, rgeos, raster, sp,
spatstat, maptools, spatialEco, dismo, pROC, kimisc, corrplot,
InPosition, lsr, gridExtra, caTools, plyr, classInt, coin, DescTools,
rWind, shape, rworldmap, cluster, RcmdrMisc, gdistance, Hmisc

In general, it is not a good idea to depend on so many packages,
because what "Depends" do is to load and attach packages. Among other
issues, there is one that you are already experimenting: "roc" is
exported both by "spatstat" and "pROC", so one masks the other.

The solution is to list them under "Imports" instead of "Depends". In
fact, my advice is to put as many packages as possible under
"Imports". Keep in "Depends" only those you would load and attach
anyway when working with your package, because you need all the
functions along with the ones your package exports. For the rest of
them, just use them as package::function to avoid this kind of
problem, and reexport functions selectively if needed.

Iñaki

PS: I'm taking a look at other packages and I see that you always use
"Depends" and never "Imports". My general advice is against this
practice. Moreover, from the "Writing R Extensions" manual:

"Field ‘Depends’ should nowadays be used rarely, only for packages
which are intended to be put on the search path to make their
facilities available to the end user (and not to the package itself):
for example it makes sense that a user of package 'latticeExtra' would
want the functions of package 'lattice' made available."



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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel



__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Iñaki Úcar
El mar., 7 ago. 2018 a las 9:32, Gianmarco Alberti
() escribió:
>
> 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
>
> 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 see:

Depends: R (>= 3.4.0), ggplot2, ggrepel, rgdal, rgeos, raster, sp,
spatstat, maptools, spatialEco, dismo, pROC, kimisc, corrplot,
InPosition, lsr, gridExtra, caTools, plyr, classInt, coin, DescTools,
rWind, shape, rworldmap, cluster, RcmdrMisc, gdistance, Hmisc

In general, it is not a good idea to depend on so many packages,
because what "Depends" do is to load and attach packages. Among other
issues, there is one that you are already experimenting: "roc" is
exported both by "spatstat" and "pROC", so one masks the other.

The solution is to list them under "Imports" instead of "Depends". In
fact, my advice is to put as many packages as possible under
"Imports". Keep in "Depends" only those you would load and attach
anyway when working with your package, because you need all the
functions along with the ones your package exports. For the rest of
them, just use them as package::function to avoid this kind of
problem, and reexport functions selectively if needed.

Iñaki

PS: I'm taking a look at other packages and I see that you always use
"Depends" and never "Imports". My general advice is against this
practice. Moreover, from the "Writing R Extensions" manual:

"Field ‘Depends’ should nowadays be used rarely, only for packages
which are intended to be put on the search path to make their
facilities available to the end user (and not to the package itself):
for example it makes sense that a user of package 'latticeExtra' would
want the functions of package 'lattice' made available."

>
> 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@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Hugh Parsonage
Does your package import or depend on 'GmAMisc'? This package appears
to Depend on both spatstat and pROC.

Alternatively you have imported both packages in your NAMESPACE.

If neither of these clues help, could you post your DESCRIPTION and
NAMESPACE files? Probably all we'd need.



On 6 August 2018 at 06:21, 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
>
> 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@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-package-devel

__
R-package-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel


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

2018-08-07 Thread Gianmarco Alberti
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

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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-package-devel