From murdoch.duncan at gmail.com  Wed Jan 16 17:40:37 2013
From: murdoch.duncan at gmail.com (Duncan Murdoch)
Date: Wed, 16 Jan 2013 11:40:37 -0500
Subject: [Rd] Declaring/importing non-exported functions [car] in
 another package
In-Reply-To: <50F6D469.3010305@yorku.ca>
References: <50F6D469.3010305@yorku.ca>
Message-ID: <50F6D805.1020309@gmail.com>

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



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