The output of Anova
is of class
anova
and data.frame
.
So, if we use the extraction with row/column names, it should work. Using a reproducible example from the ?Anova
documentation
library(car)
mod <- lm(conformity ~ fcategory*partner.status, data=Moore,
contrasts=list(fcategory=contr.sum, partner.status=contr.sum))
out <- Anova(mod, type = 3)
str(out)
#Classes ‘anova’ and 'data.frame': 5 obs. of 4 variables:
# $ Sum Sq : num 5753 36 240 175 818
# $ Df : num 1 2 1 2 39
# $ F value: num 274.359 0.859 11.425 4.185 NA
# $ Pr(>F) : num 3.05e-19 4.31e-01 1.66e-03 2.26e-02 NA
# - attr(*, "heading")= chr "Anova Table (Type III tests)\n" "Response: conformity"
The print
method changes the way how it is printing the output. But, if we just strip off the anova
class. The "Residuals" are also in the row names
row.names(out)
#[1] "(Intercept)" "fcategory" "partner.status"
#[4] "fcategory:partner.status" "Residuals"
So, using the row/column names for extraction
out["Residuals","Sum Sq"]
#[1] 817.764