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

Michael Friendly friendly at yorku.ca
Wed Jan 16 18:28:30 CET 2013


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



More information about the R-devel mailing list