[Rd] conflicting imports despite using importFrom in NAMESPACE

Jombart, Thibaut t.jombart at imperial.ac.uk
Wed Jun 5 18:48:28 CEST 2013


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
exportPattern(".")

## Export all classes
exportClassPattern(".")

## 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:
> library(foo)
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:
http://stackoverflow.com/questions/8637993/better-explanation-of-when-to-use-imports-depends
clarified things a bit, but I still don't understand the warning above.

Any clarification will be much appreciated.

All the best

Thibaut

-- 
######################################
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
http://sites.google.com/site/thibautjombart/
http://adegenet.r-forge.r-project.org/


More information about the R-devel mailing list