[Rd] Declaring/importing non-exported functions [car] in another package

Michael Friendly friendly at yorku.ca
Wed Jan 16 18:52:15 CET 2013


On 1/16/2013 12:26 PM, John Fox wrote:
> Dear Duncan and Michael,
>
> My initial reaction is that I'd rather not export these functions from the car package since the package already has many exported functions and the functions in question perform low-level operations that won't be of interest to end users. I recognize, however, the functions (and possibly some others) may be useful in other packages, such as heplots, so I'll think about this some more.
This is why I wrote directly to R-devel rather than to you.  It is 
low-level, and doesn't need to be exported.
OTOH, it provides an elegant way to provide Sheffe-type intervals & 
ellipses as you do in car::confidenceEllipse,
which I copied.

best,
-Michael

>
> Following up on Michael's subsequent message in this thread, I find the current text in Sec. 1.6.1 ("Specifying imports and exports") of Writing R Extensions reasonably clear.
>
> Best,
>   John
>
> On Wed, 16 Jan 2013 11:40:37 -0500
>   Duncan Murdoch <murdoch.duncan at gmail.com> wrote:
>> On 13-01-16 11:25 AM, Michael Friendly wrote:
>>> A new function in my heplots package wants to use a non-exported utility
>>> function in the car package,
>>> df.terms, but this depends on other non-exported functions.
>>>    From the Writing R extensions manual, I thought I could do this via (in
>>> my NAMESPACE)
>>>
>>> importFrom(car, car:::df.terms, car:::df.terms.default, car:::is.aliased)
>>>
>>> but I get:
>>> ** preparing package for lazy loading
>>> Error : objects 'car:::df.terms', 'car:::df.terms.default',
>>> 'car:::is.aliased' are not exported by 'namespace:car'
>>> ERROR: lazy loading failed for package 'heplots'
>>>
>>> \S 1.6.1 of the manual says regarding importFrom():
>>> Using |foo:::f| instead of |foo::f| allows access to unexported objects.
>>> This is generally not recommended, as the semantics of unexported
>>> objects may be changed by the package author in routine maintenance.
>>>
>>> Questions:
>>> 1.  Why doesn't this work?
>> I think you misread the manual.  It is talking about ways to access functions other than by using importFrom.  You can use car:::df.terms in your functions.
>>
>>> 2.  Is my only alternative to copy these functions to my package, also
>>> unexported?
>> Using car:::df.terms explicitly is another option.
>>
>> Another possibility is for the car maintainer (John Fox) to export that function from car.
>>
>> Duncan Murdoch


-- 
Michael Friendly     Email: friendly AT yorku DOT ca
Professor, Psychology Dept. & Chair, Quantitative Methods
York University      Voice: 416 736-2100 x66249 Fax: 416 736-5814
4700 Keele Street    Web:   http://www.datavis.ca
Toronto, ONT  M3J 1P3 CANADA



More information about the R-devel mailing list