[R] aov summary to matrix
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) block5 343.29 68.66 4.4467 0.015939 * N1 189.28 189.28 12.2587 0.004372 ** P1 8.408.40 0.5441 0.474904 K1 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.480.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 block5 343.29 68.66 4.4467 0.015939 N1 189.28 189.28 12.2587 0.004372 P1 8.408.40 0.5441 0.474904 K1 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.480.48 0.0312 0.862752 Residuals 12 185.29 15.44NA NA Thanks, - Moises __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] aov summary to matrix
On Tue, 17 Aug 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. You are confusing the printed representation with the object (which seems today's favourite misconception). as.matrix(summary(npk.aov)[[1]]) is a matrix (to full precision) as you seek, although I would prefer to work with the data frame which is returned. (Note: your output is from MASS4 example(aov), unattributed.) For example, convert Df Sum Sq Mean Sq F value Pr(F) block5 343.29 68.66 4.4467 0.015939 * N1 189.28 189.28 12.2587 0.004372 ** P1 8.408.40 0.5441 0.474904 K1 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.480.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 block5 343.29 68.66 4.4467 0.015939 N1 189.28 189.28 12.2587 0.004372 P1 8.408.40 0.5441 0.474904 K1 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.480.48 0.0312 0.862752 Residuals 12 185.29 15.44NA NA -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Re: [R] aov summary to matrix
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) block5 343.29 68.66 4.4467 0.015939 * N1 189.28 189.28 12.2587 0.004372 ** P1 8.408.40 0.5441 0.474904 K1 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.480.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 block5 343.29 68.66 4.4467 0.015939 N1 189.28 189.28 12.2587 0.004372 P1 8.408.40 0.5441 0.474904 K1 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.480.48 0.0312 0.862752 Residuals 12 185.29 15.44NA 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 __ [EMAIL PROTECTED] mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html