Re: [Rd] importing S3 methods with importFrom

From: Uwe Ligges <ligges_at_statistik.tu-dortmund.de>
Date: Wed, 11 Jan 2012 15:28:53 +0100

This is a problem in the lmtest package:

"lrtest.default" is exported as a function rather than declared as an S3method in its NAMESPACE. I am CCing the maintainer. For the meantime, you hav to import the default function explicitly, I believe.

Best,
Uwe Ligges

On 10.01.2012 19:17, Stephanie M. Gogarten wrote:
> In my own package, I want to use the default S3 method of the generic
> function lrtest() from the lmtest package. Since I need only one
> function from lmtest, I tried to use importFrom in my NAMESPACE:
>
> importFrom(lmtest, lrtest)
>
> However, this fails R CMD check in the examples:
> Error in UseMethod("lrtest") :
> no applicable method for 'lrtest' applied to an object of class
> "c('glm', 'lm')"
> Calls: assocTestRegression ... append -> RunRegression -> append ->
> unlist -> lrtest
>
> Relevant line of code in assocTestRegression is
> tmp <- append(tmp, unlist(lrtest(mod, mod0))[c(8,10)])
> where mod and mod0 are both results of the glm() function.
>
> If I instead import the entire package in my NAMESPACE:
>
> import(lmtest)
>
> The example runs without error. Is there a way to import all methods for
> an S3 generic function without importing the entire package?
>
> thanks,
> Stephanie Gogarten
>
> sessionInfo()
> R version 2.14.0 (2011-10-31)
> Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
>
> locale:
> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] lmtest_0.9-28 zoo_1.7-4
>
> loaded via a namespace (and not attached):
> [1] grid_2.14.0 lattice_0.20-0 tools_2.14.0
>
> ______________________________________________
> R-devel_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed 11 Jan 2012 - 14:57:31 GMT

This quarter's messages: by month, or sorted: [ by date ] [ by thread ] [ by subject ] [ by author ]

All messages

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Wed 11 Jan 2012 - 15:20:08 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive