[R] aov summary to matrix
Sundar Dorai-Raj
sundar.dorai-raj at PDF.COM
Tue Aug 17 23:46:02 CEST 2004
Moises Hassan wrote:
> Is there an easy way of converting an aov.summary into a matrix in which
> the rows are the factor names and the columns are Df, Sum Sq, Mean Sq, F
> value and Pr.
>
> For example, convert
>
> Df Sum Sq Mean Sq F value Pr(>F)
> block 5 343.29 68.66 4.4467 0.015939 *
> N 1 189.28 189.28 12.2587 0.004372 **
> P 1 8.40 8.40 0.5441 0.474904
> K 1 95.20 95.20 6.1657 0.028795 *
> N:P 1 21.28 21.28 1.3783 0.263165
> N:K 1 33.14 33.14 2.1460 0.168648
> P:K 1 0.48 0.48 0.0312 0.862752
> Residuals 12 185.29 15.44
> ---
> Signif. codes: 0 `***' 0.001 `**' 0.01 `*' 0.05 `.' 0.1 ` ' 1
>
>
> To
>
> Factor Df Sum Sq Mean Sq F value Pr
> block 5 343.29 68.66 4.4467 0.015939
> N 1 189.28 189.28 12.2587 0.004372
> P 1 8.40 8.40 0.5441 0.474904
> K 1 95.20 95.20 6.1657 0.028795
> N:P 1 21.28 21.28 1.3783 0.263165
> N:K 1 33.14 33.14 2.1460 0.168648
> P:K 1 0.48 0.48 0.0312 0.862752
> Residuals 12 185.29 15.44 NA NA
>
>
Try this:
example(aov)
as.data.frame.summary.aovlist <- function(x) {
if(length(x) == 1) {
as.data.frame(x[[1]])
} else {
lapply(unlist(x, FALSE), as.data.frame)
}
}
x1 <- summary(npk.aov)
x2 <- summary(npk.aovE)
as.data.frame(x1)
as.data.frame(x2)
--sundar
More information about the R-help
mailing list