From ripley at stats.ox.ac.uk  Sun Aug 26 19:27:24 2012
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Sun, 26 Aug 2012 18:27:24 +0100
Subject: [Rd] Package "datasets" not exporting anything on a recent
	R-2.15.1-patched
In-Reply-To: <503A5AEB.3050502@gmail.com>
References: <503A4DEB.2090605@gmail.com> <503A56E1.2080900@stats.ox.ac.uk>
	<503A5AEB.3050502@gmail.com>
Message-ID: <503A5C7C.3030806@stats.ox.ac.uk>

On 26/08/2012 18:20, Laurent Gautier wrote:
> On 2012-08-26 19:03, Prof Brian Ripley wrote:
>> On 26/08/2012 17:25, Laurent Gautier wrote:
>>> Hi,
>>>
>>> I just stumbled on the following apparent oddity: the package "datasets"
>>> does not appear to export anything out of its namespace:
>>>
>>>  > ns_datasets <- getNamespace('datasets')
>>>  > getNamespaceExports(ns_datasets)
>>> character(0)
>>>
>>> Not the case with other packages (example here with "utils"):
>>>  > ns_utils <- getNamespace('utils')
>>>  > head(getNamespaceExports(ns_utils))
>>> [1] "?"            ".DollarNames" "adist"        "alarm" "apropos"
>>> [6] "aregexec"
>>>
>>> Is this a temporary glitch, or is there something new and specific to
>>> "datasets" ?
>>
>> Not new, been so since R 2.14.0.
>>
>> The package contains no R code: the only reason it has a namespace is
>> that since 2.14.0 all packages must have one.
>>
>> There are other data-only packages, but not in base R.
>>
>> Lazy-loaded data has not been part of the namespace for a long time:
>> they are directly in the package's environment.  The reason is the
>> namespace scoping rules: if the package's datasets were in its
>> namespace, they would be found before any other dataset of that name
>> by the package's R functions.
>>
> Thanks for the quick answer and explanations. The last paragraph above
> is leaving me with the wish to understand more before I comment on it.
> Would you have an example of finding a dataset in a package's namespace
> (before a dataset with the same name in an other package further down in
> the search path) being a problem ?

It does not happen now, but for example MASS contains both datasets and 
analysis functions and when the datasets were in the namespace you got 
them before other datasets (e.g. modified versions) of the same name.

>
>
> Best,
>
> Laurent


-- 
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] Package "datasets" not exporting anything on a recent R-2.15.1-patched
Prof Brian Ripley