I am an R and coding newbie, so please bear with me. My data looks like this:
Names Prof_A Prof_B...............Prof_Z cond
Aaliya 2.1 3.1 ................ 2.3 A
Adam 1.87 2.3 .................2.2 A
.
.
Brett 1.69 2.6...................1.78 B
etc (approx. 1700 observations)
I am trying to run an ANOVA through each numeric column, followed by Tukey's test. I want to print only significant values of the contrasts.
library(car)
require(graphics)
options(max.print = 99999)
ANV <- rep(NA,ncol(total))
sink("Anova-Tukey-sig.doc")
for (i in 2:(ncol(total)-1)) {
column <- names(total[i])
ANV <- summary(aov(total[,i]~cond,data=total))
posthocresult <- TukeyHSD(aov(total[,i]~cond,data=total))
print(column)
print(ANV)
print(posthocresult[posthocresult$cond[,4]<=.05])
}
sink()
However, the code gives me a weird output like this I am giving some snippets):
[1] "Prof_A"
Df Sum Sq Mean Sq F value Pr(>F)
cond 25 0.0228 0.0009111 1.864 0.00597 **
Residuals 1690 0.8262 0.0004889
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
named list()
[1] "Prof_B"
Df Sum Sq Mean Sq F value Pr(>F)
cond 25 0.0468 0.0018719 2.889 2.54e-06 ***
Residuals 1690 1.0949 0.0006479
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$<NA>
NULL
$<NA>
NULL
$<NA>
NULL
Skipping some output
[1] "Prof_R"
Df Sum Sq Mean Sq F value Pr(>F)
cond 25 0.0284 0.0011345 3.404 3.1e-08 ***
Residuals 1690 0.5633 0.0003333
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
$cond
diff lwr upr p adj
B-A 9.802223e-03 1.237889e-03 0.0183665561 6.894820e-03
C-A 6.243324e-03 -1.302350e-03 0.0137889986 2.940579e-01
D-A 1.054579e-02 1.713554e-03 0.0193780265 3.204823e-03
E-A 4.295824e-03 -3.942431e-03 0.0125340784 9.752564e-01
F-A 4.607934e-03 -8.302024e-03 0.0175178915 9.999225e-01
etc. Can someone please help?