# ferdo Lab — WEEK 4 · PUBLIC ORIGINAL INSTRUCTOR SOLUTION
# All data synthetic. Run from extracted package root. Base R only.
atsq <- read.csv("data/atsq.csv")
background <- read.csv("data/background.csv")
d <- merge(atsq,background,by="id")
print(head(d))
hist(d$atsqTotal,breaks=5,main="Synthetic ATSQ totals",
     xlab="Illustrative score")
plot(d$age,d$atsqTotal,pch=19,xlab="Age",ylab="Synthetic ATSQ score")
boxplot(atsqTotal~Coding,data=d,xlab="Prior coding",
        ylab="Synthetic ATSQ score",main="Distribution by coding")
print(aggregate(atsqTotal~Coding,d,mean))
stopifnot(nrow(d)==12L,all(is.finite(d$atsqTotal)))
cat("W4 PASS: 12 synthetic matched records\n")
# A conventional boxplot displays median and quartiles (IQR);
# neither it nor a cross-sectional scatterplot proves causality.
