How to isolate a factor from a result as a vector?

1

I want to isolate a factor from the result and leave it as vector so you can use this factor in another formula.

Example:

library(drc)
data=S.alba
dados$Dose <- as.factor(dados$Dose)
alba.aov <- aov(DryMatter~Dose, data=dados)
summary(alba.aov)

            Df Sum Sq Mean Sq F value Pr(>F)    
Dose         7 121.17  17.310   53.04 <2e-16 ***
Residuals   60  19.58   0.326                   
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1

I'd like to isolate only the Sum Sq from the Dose. So you could use it in other formulas without having to look for the exact value and changing formula by formula.

Example 2:

SumSqDose <- C(valor do Sum Sq alba.aov)

Instead of writing a formula like this: (121,17/7) It would look something like this: (SumSqDose/7)

Does anyone know how to extract this value without having to search one by one?

    
asked by anonymous 18.02.2018 / 01:34

1 answer

4

The output of summary() is a list object. Among the various options, here are two:

Option 1:

  sm <- summary(alba.aov)

  sm <- unlist(sm)
  names(sm) # para indentificar o que você quer (no seu caso o elemento 3)
  sm[3]

Option 2:

You select the first element in the list, where all information is saved, and uses the str() function to identify all elements of the object:

  sm <- summary(alba.aov)

  str(sm[[1]])
  sm[[1]]$'Sum Sq'[1]
    
18.02.2018 / 01:56