From friendly at yorku.ca  Wed Jan 16 18:28:30 2013
From: friendly at yorku.ca (Michael Friendly)
Date: Wed, 16 Jan 2013 12:28:30 -0500
Subject: [Rd] Declaring/importing non-exported functions [car] in
 another package
In-Reply-To: <50F6D805.1020309@gmail.com>
References: <50F6D469.3010305@yorku.ca> <50F6D805.1020309@gmail.com>
Message-ID: <50F6E33E.2080302@yorku.ca>

On 1/16/2013 11:40 AM, Duncan Murdoch wrote:
>
>> 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.
>
Hmm.  It turns out that this is a bit more complicated, since 
car::df.terms is an S3 generic,
relying on car:::df.terms.default().

In my function, I am now using car::: explicitly--

     # determine "size" of intervals [perhaps need importFrom(car, 
car:::df.terms, ...) in NAMESPACE?]
     if(is.null(df)) {
       df <- if (Scheffe) sum(car:::df.terms(object)) else 2
   }

However, when I removed the definitions of the subsidiary 
df.terms.default from my package, R CMD check
complains bitterly:

 > coefplot(mod, add=TRUE, Scheffe=TRUE, fill=TRUE)
Error in UseMethod("df.terms") :
   no applicable method for 'df.terms' applied to an object of class 
"c('mlm', 'lm')"
Calls: coefplot -> coefplot.mlm -> <Anonymous>
Execution halted

So, the semantics of importFrom() do not allow non-exported functions (I 
still wonder why), and my only direct option is to
copy these functions to my package.

-Michael

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



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