[Rd] another import puzzle

From: Ben Bolker <bbolker_at_gmail.com>
Date: Sat, 26 Mar 2011 14:14:12 -0400

  Dear list,

  I have another (again possibly boneheaded) puzzle about importing, again encapsulated in a nearly trivial package. (The package is posted at <http://www.math.mcmaster.ca/bolker/misc/coefsumtest_0.001.tar.gz>.)

  The package consists (only) of the following S3 method definitions:

coeftab <- function(object, ...) UseMethod("coeftab",object) coeftab.default <- function(object,...) {   print(class(summary(object)))

  The NAMESPACE tries to pull in the necessary bits and pieces from lme4 to extract summaries and coefficients:

importClassesFrom(lme4,"mer","summary.mer") importMethodsFrom(lme4,"coef","summary","show","print") exportMethods("coef","summary","show","print") exportClasses("mer","summary.mer")

  The package passes the routine parts of R CMD check. The following test shows that, with lme4 loaded, coef(summary([object of class "mer"])) works in the global environment, but not in a function defined inside the namespace of the package.

  The output ends with:

> coeftab.default(gm1)

[1] "summaryDefault" "table"
Error in object$coefficients : $ operator is invalid for atomic vectors Calls: coeftab.default -> coef -> coef -> coef.default

  which indicates that inside the function, summary() is calling summary.default instead of seeing the summary method for "mer" objects ...

  I have (re-re-re-)read the appropriate R-exts section, without luck, and tried various minor variations (e.g. import()ing all of lme4, changing the order of the directive, ...).

  Help ... ?

    Ben Bolker



gm1 <- glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),

             family = binomial, data = cbpp)

coef(summary(gm1)) ## works

f <- function(g) {
f(gm1) ## works

coeftab.default(gm1) ##

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Sat 26 Mar 2011 - 18:16:58 GMT

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 Sat 26 Mar 2011 - 19:30:38 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