# MinutePlot validation -- Two-way mixed ANOVA (one between, one within)
# Install once (skip on later runs):
#   install.packages(c("ez"))   # exactly what THIS script uses

# Load packages (every session):
library(ez)

# Versions (compare against those stated on this page):
cat(R.version.string, "\n")
for (p in c("ez")) cat(p, as.character(packageVersion(p)), "\n")

# Load data:
d <- read.csv("mixed_longitudinal_r.csv")   # same folder as script
d$subject <- factor(d$subject); d$group <- factor(d$group); d$time <- factor(d$time)

# Analysis (one print per table shown on the page, in page order):
print(summary(aov(value ~ group * time + Error(subject/time), data = d)))   # group against subjects-within-group; time and group:time against the within stratum
print(ezANOVA(d, dv = value, wid = subject, between = group, within = time, detailed = TRUE))
