I'm sorry I haven't boiled this down to a more-minimal example yet, but ...
I'm working on an S3 method (tidy.merMod, in the 'broom' package). It normally handles 'merMod' objects from the lme4 package, but I'm trying to make it handle 'merModLmerTest' objects from the lmerTest package too. The merModLmerTest class inherits (as an S4) class from the merMod class. The important difference (for my current purposes) is that summary.merMod returns an object containing a coefficient table *without* degrees or freedom or p-values, while the summary method for merModLmerTest objects returns one *with* both of those columns. Because merModLmerTest inherits from merMod, calling tidy(obj) on a merModLmerTest object does get you into broom:::tidy.merMod. Within that function, though, calling summary() appears to call summary.merMod instead of merModLmerTest, so I don't get the additional columns I want. Ideas/directions for further diagnoses? Is this an S3/S4 confusion, or something funny about the way the broom and merModLmerTest package are talking to each other, or ... ? cheers Ben Bolker ---- library(lme4) fm1 <- lmer(Reaction~Days+(Days|Subject),sleepstudy) library(lmerTest) fm1B <- as(fm1,"merModLmerTest") coef(summary(fm1B)) ## table with df and p values coef(lme4:::summary.merMod(fm1B)) ## table without df and p values is(fm1B,"merMod") ## TRUE library(broom) tidy(fm1B) ## hard to show what's going on without debugging through the function: ## the issue occurs here: ## https://github.com/dgrtwo/broom/blob/master/R/lme4_tidiers.R#L94 I can't replicate this behaviour with a trivial method ... silly <- function(x, ...) { UseMethod("silly") } silly.merMod <- function(object, ...) { coef(summary(object)) } silly(fm1B) environment(silly) <- environment(tidy) silly(fm1B) ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel