I have a large dataset on which I am performing ANOVA analysis. I'm not sure how to get the output of the analysis into a table that I can use in a Word document (without retyping all of the values manually).
Here is an example of what I'm trying to do:
var1 <- c("Red", "Green", "Blue", "Blue", "Red","Red", "Green", "Blue", "Blue", "Red",
"Red", "Blue", "Green", "Blue", "Red","Red", "Green", "Blue", "Blue", "Red")
var2 <- c(10, 20, 15, 32, 10, 20, 15, 32, 10, 20, 15, 32, 10, 20, 15, 32, 10, 20, 15, 32)
df <- data.frame(var1, var2)
TukeyHSD(aov(var2 ~ var1))
This produces an output that looks like this:
Tukey multiple comparisons of means
95% family-wise confidence level
Fit: aov(formula = var2 ~ var1)
$var1
diff lwr upr p adj
Green-Blue -8.25 -21.183389 4.683389 0.2580147
Red-Blue -2.75 -13.310068 7.810068 0.7848043
Red-Green 5.50 -7.433389 18.433389 0.5323260
I would like the output to be in a format that is easy to cut and paste into Word that includes the headings, "Variable", "Difference" and "p value". Any help would be appreciated.