[Rd] namespace magic

Prof Brian Ripley ripley at stats.ox.ac.uk
Mon Aug 4 12:05:39 MEST 2003


On Thu, 31 Jul 2003, Roger Koenker wrote:

> I'm confused about name spaces.  This morning I installed the
> boot package because I wanted to look at bca.ci.  So I did
> library(boot), but then I had,
> 
> > bca.ci
> Error: Object "bca.ci" not found
> 
> I had a look in the boot R directory and bca.ci was there as expected.
> So then I took a look at the NAMESPACE file for the boot package and saw
> that bca.ci wasn't exported.  I tried
> 
> example(boot.ci)
> 
> and this worked fine including computing the bca.ci version of some
> intervals.  Finally, I read the section on name spaces in Writing R
> extensions, which was very helpful but still didn't answer my basic
> question:  how is it that bca.ci is not loaded and still available
> to do the example?  And why not export bca.ci and friends?

The answer to the last question is because they are internal functions for 
the boot package.  They are available to functions in the boot package, 
and to functions in any other package with a namespace that imports them.

You can look at non-exported functions by

getFromNamespace("bca.ci", "boot")  # without even library(boot)
getAnywhere("bca.ci")

and in R-devel

boot:::bca.ci



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



More information about the R-devel mailing list