[R] Problem with Anova() in package "car"

Gang Chen gangchen6 at gmail.com
Tue Jan 13 19:48:21 CET 2015


I'm having some trouble with Anova() in package "car". When the model
formula is explicitly expressed:

library('nlme')
library('car')
fm <- lme(distance ~ age + Sex, data = Orthodont, random = ~ 1)

Anova() works fine:

Anova(fm)

However, if the model formula is scanned from an external source:

myModel <- as.formula("distance ~ age + Sex")
fm2 <- lme(myModel, data = Orthodont, random = ~ 1)

I get the following error:

Anova(fm2)
Error: object of type 'symbol' is not subsettable

How to resolve the situation when the model formula is defined externally?

Thanks,
Gang



More information about the R-help mailing list