[Rd] importing S3 methods with importFrom

From: Stephanie M. Gogarten <sdmorris_at_u.washington.edu>
Date: Tue, 10 Jan 2012 10:17:42 -0800


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 Received on Wed 11 Jan 2012 - 12:34:18 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:10: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