How to subset from aov summary in R?

Maybe this is a simple question but I'm wondering how can I subset DF and F.values for the terms appearing in an aov summary?

For example, using the base R built-in dataset npk, how can I extract the residual and other DFs and F.values that appear in the summary of the following model:

fit <- summary(aov(yield ~ block + N * P + K, data = npk)) # example is fully reproducible

P.S. I'm looking for base R solutions.

1 answer

  • answered 2018-05-16 06:18 akrun

    The fit output is a list of length 1 (by checking str(fit)). We extract it with [[ and then do $ or [[ to extract the components

    fit[[1]]$Df
    #[1]  5  1  1  1  1 14 #where 14 is the Residuals df
    fit[[1]]$`F value`
    #[1]  4.391098 12.105541  0.537330  6.088639  1.361073        NA