When extracting elements from a named list, R automatically drops the names when the list is of length 1. Is it possible to keep the names?
Exemple:
Code:R
lin_mod = lm(data, CompStength~ .)
anova(lin_model)
anova(lin_model)[,"Sum Sq"]
does not keep the names (e.g. CA.TA, TA.C, ...) but returns
[1] 86.103991 2331.962769 932.229151 1415.558985 457.608362
I would like to get:
Sum Sq
CA.TA 86.1
TA.C 2332.0
W.C 932.2
Just as when I run anova(lin_model)[,c("Sum Sq","Df")]
I get:
Sum Sq Df
CA.TA 86.1 3
TA.C 2332.0 3
W.C 932.2 2
Temp 1415.6 2