From ripley at stats.ox.ac.uk  Tue Jun 13 14:28:52 2006
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 13 Jun 2006 13:28:52 +0100 (BST)
Subject: [Rd] about integration of a  library into package creation
In-Reply-To: <448E94DE.6090903@stats.uwo.ca>
References: <448D81F9.8040406@jouy.inra.fr> <448D864F.2070704@stats.uwo.ca>
	<Pine.LNX.4.64.0606121652510.31903@gannet.stats.ox.ac.uk>
	<448D955F.9050201@jouy.inra.fr>
	<448D9790.5030609@stats.uwo.ca> <448DA538.8050100@jouy.inra.fr>
	<448DA8D4.5050704@statistik.uni-dortmund.de>
	<448E8D71.40301@jouy.inra.fr> <448E94DE.6090903@stats.uwo.ca>
Message-ID: <Pine.LNX.4.64.0606131315100.30395@gannet.stats.ox.ac.uk>

On Tue, 13 Jun 2006, Duncan Murdoch wrote:

[...]

> However, it appears that you can only import packages that have a namespace. 
> (I was unaware of this restriction; perhaps it's not really true, and the 
> error message means something else.)

Yes, it is true but not properly documented.  The description in R-exts is

   All packages implicitly import the base name space.  Variables from
   other packages need to be imported explicitly using the directives
   @code{import} and @code{importFrom}.  The @code{import} directive
   imports all exported variables from the specified package(s).  Thus the
   directives

and that needs to be qualified in at least two ways:

- all packages with namespaces implicitly import the base name space.
- Variables from other packages with a namespace ...

as the concept of `exported variables' only applied to a namespaces.

The terminology is also a little confusing: we have

   importFrom(foo, f, g)

   specifies that the exported variables @code{f} and @code{g} of the
   package @pkg{foo} are to be imported.
   ^^^^^^^
but the error message is of the form

Error in importIntoEnv(impenv, impnames, ns, impvars) :
         object 'print.summary.lm' is not exported by 'namespace:stats'
                                                       ^^^^^^^^^

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] about integration of a library into package creation
Prof Brian Ripley