#Pollution data from Rao, p. 137) location=as.factor(c(rep("up",10),rep("down",15))) level=c(24.5,29.7,20.4,28.5,25.3,21.8,20.2,21.0,21.9,22.2,32.8,30.4,32.3,26.4,27.8, 26.9,29.0,31.5,31.2,26.7,25.6,25.1,32.8,34.3,35.4) pollution=data.frame(cbind(location,level)) #EDA--resize plot window par(mfrow=c(1,2)) qqnorm(level[location=="up"],main="Up",pty="s") qqnorm(level[location=="down"],main="Down",pty="s") t.test(level~location,data=pollution,conf.level=0.95,alt="two.sided",var.equal=TRUE) var.test(level~location,data=pollution) #Not the folded F-test # Summary graph layout(mat = matrix(c(1,2,3),3,1,byrow=TRUE), height = c(1,1,1)) #Histogram display will be three times taller than the boxplot par(mar=c(3.1, 3.1, 1.1, 2.1)) plotrange=c(range(level)[1]-sd(level),range(level)[2]+sd(level)) hist(level[location=="up"],xlim=plotrange,col="pink",ylab="",prob=TRUE,main="Up") lines(density(level[location=="up"]),col="red",lwd=2) hist(level[location=="down"],xlim=plotrange,col="pink",ylab="",prob=TRUE,main="Down") lines(density(level[location=="down"]),col="red",lwd=2) boxplot(level~location,data=pollution, horizontal=TRUE, outline=TRUE,ylim=plotrange, frame=F, col = "green1")