[Rd] conflicting imports despite using importFrom in NAMESPACE
t.jombart at imperial.ac.uk
Wed Jun 5 21:57:41 CEST 2013
thanks, this is reassuring - I'm assuming it is just a problem on my computer then.
Thanks for pointing out the exportPattern("."). For some purposes I actually ended up needing to export some hidden functions, but I guess I could just not export these and reference to them explicitly using ':::'.
From: Martin Morgan [mtmorgan at fhcrc.org]
Sent: 05 June 2013 20:19
To: peter dalgaard
Cc: Jombart, Thibaut; r-devel at r-project.org
Subject: Re: [Rd] conflicting imports despite using importFrom in NAMESPACE
On 06/05/2013 11:59 AM, peter dalgaard wrote:
> I'd suspect that the Imports: line in DESCRIPTION imports the full namespaces, including conflicting items, on top of importFrom items. Does it not help to use Depends: instead?
I think of Imports: and Depends: as different -- presumably the end user has no
need for ape / igraph beyond the functionality provided by the new package.
For what it's worth, with a minimal package (attached, modulo the mailman gods),
$ tree PkgA
1 directory, 2 files
and with DESCRIPTION / NAMESPACE as below, I don't see any warning about
replacing previous imports
$ R --vanilla
R version 3.0.1 beta (2013-05-07 r62721)
Platform: x86_64-unknown-linux-gnu (64-bit)
 LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
 LC_TIME=en_US.UTF-8 LC_COLLATE=en_US.UTF-8
 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
 LC_PAPER=C LC_NAME=C
 LC_ADDRESS=C LC_TELEPHONE=C
 LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
 stats graphics grDevices utils datasets methods base
other attached packages:
loaded via a namespace (and not attached):
 ape_3.0-8 grid_3.0.1 igraph_0.6.5-2 lattice_0.20-15
likewise with R version 3.0.1 beta (2013-05-07 r62721).
Also I don't think exportPattern(".") is to be recommended; see section 1.5.1 of
Writing R Extensions (though as a lazy programmer I kind of like the pattern
> On Jun 5, 2013, at 18:48 , Jombart, Thibaut wrote:
>> Dear all,
>> It is my understanding that using 'importFrom' in the NAMESPACE of a package allows to avoid conflicts between different packages defining objects with identical names. However, I can still see conflicts while loading the package using 'library'.
>> Here is a toy example, with a package 'foo' importing 'as.igraph' from the igraph package, and 'nj' from ape.
>> 'foo' uses the following DESCRIPTION file:
>> Package: foo
>> Version: 0.0-0
>> Date: 2013/06/04
>> Title: foo
>> Author: John Doe
>> Maintainer: John Doe <jdoe at nowhere.org>
>> Imports: igraph, ape
>> Description: just a test.
>> License: GPL (>=2)
>> LazyLoad: yes
>> And the following NAMESPACE:
>> ## Export all names
>> ## Export all classes
>> ## Import all packages listed as Imports or Depends
>> importFrom(igraph, as.igraph)
>> importFrom(ape, nj)
>> The check (R 3.0.1) passes without warnings, but then when loading the package:
>> Warning messages:
>> 1: replacing previous import ‘as.igraph’ when loading ‘ape’
>> 2: replacing previous import ‘edges’ when loading ‘ape’
>> I would have assumed only ape::nj and igraph::as.igraph would be imported when loading 'foo', so this conflict should not occur.
>> There is probably something simple I have missed as I have just began to pay attention to NAMESPACES recently. Reading this post:
>> clarified things a bit, but I still don't understand the warning above.
>> Any clarification will be much appreciated.
>> All the best
>> Dr Thibaut JOMBART
>> MRC Centre for Outbreak Analysis and Modelling
>> Department of Infectious Disease Epidemiology
>> Imperial College - School of Public Health
>> St Mary’s Campus
>> Norfolk Place
>> London W2 1PG
>> United Kingdom
>> Tel. : 0044 (0)20 7594 3658
>> t.jombart at imperial.ac.uk
>> R-devel at r-project.org mailing list
Computational Biology / Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N.
PO Box 19024 Seattle, WA 98109
Location: Arnold Building M1 B861
Phone: (206) 667-2793
More information about the R-devel