my.numbers <- c(2,4,3,6,5,7) plot(1:100,c(rep(60,50),rep(80,50)),type='n') abline(h=70) for (i in 1:100) { sample <- rnorm(36,70,12) # ci <- t.test(sample)$conf.int ci <- c(mean(sample) - 1.96*2,mean(sample) + 1.96*2) lines(c(i,i),c(ci[1],ci[2]),col=ifelse(ci[1]<70&&ci[2]>70,'black','red')) points(i,mean(sample),col=ifelse(ci[1]<70&&ci[2]>70,'black','red')) } abline(h=66,lty=2) abline(h=74,lty=2) # confidence interval and hypothesis examples: treat <- scan("http://math.uttyler.edu/nathan/classes/statistics/data/reading-treatment.data") control <- scan("http://math.uttyler.edu/nathan/classes/statistics/data/reading-control.data") summary(treat) summary(control) boxplot(treat,control) t.test(treat,control,alternative='greater') t.test(treat,control,alternative='greater',var.equal=TRUE)