#————————————————————————————————————————————————————————————————————————————
# Between-Subject Analysis of Variance
# Example 1a: Between-Subject ANOVA
aov.b(hp ~ gear, data = mtcars)
# Example 1b: Between-Subject ANOVA
# Print descriptive statistics and Tukey HSD post hoc test
aov.b(hp ~ gear, data = mtcars, descript = TRUE, posthoc = TRUE)
# Example 1c: Between-Subject ANOVA, print eta-squared and omega-squared
aov.b(hp ~ gear, data = mtcars, effsize = TRUE)
#————————————————————————————————————————————————————————————————————————————
# Plot
# Example 2a: Plot results, default setting
aov.b(hp ~ gear, data = mtcars, plot = TRUE)
# Example 2b: Plot results
# No bars, draw points representing means and jittered data points
aov.b(hp ~ gear, data = mtcars, plot = TRUE, bar = FALSE, point = TRUE, jitter = TRUE)
# Example 2c: Plot results using the plot() function, use additional arguments
# see Details in the help page of the function plot.misty.object
object <- aov.b(hp ~ gear, data = mtcars)
plot(object, jitter = TRUE, jitter.alpha = 0.4, title = "Between-Subject ANOVA")
#————————————————————————————————————————————————————————————————————————————
# Create Plot Manually
# Load ggplot2 package
library(ggplot2)
# Create misty object
object <- aov.b(hp ~ gear, data = mtcars)
# Example 3: Plot
ggplot(object$result$descript, aes(group, y)) +
geom_bar(aes(group, m), stat = "summary", fun = "mean") +
geom_jitter(data = object$data, aes(group, y), alpha = 0.1, width = 0.05,
height = 0, size = 1.25) +
geom_point(aes(group, m), stat = "identity", size = 3) +
geom_errorbar(aes(group, m, ymin = low, ymax = upp), width = 0.1) +
theme_bw()
#————————————————————————————————————————————————————————————————————————————
# Write Results and Save Plot
if (FALSE) {
# Example 4a: Write results into a text file
aov.b(hp ~ gear, data = mtcars, write = "ANOVA.txt")
# Example 4b: Write results into an Excel file
aov.b(hp ~ gear, data = mtcars, write = "ANOVA.xlsx")
# Example 4c: Save plot as PNG fine
aov.b(hp ~ gear, data = mtcars, plot = TRUE, filename = "ANOVA.png",
width = 6, height = 5)
}
Run the code above in your browser using DataLab