#Paired data from Lecture 2 control=c(1.321,1.423,2.682,0.934,1.230,1.670,3.201) trt=c(0.841,0.932,2.011,0.762,0.991,1.120,2.312) diff=control-trt t.test(control,trt,paired=TRUE,alt="greater") t.test(control,trt,paired=TRUE,alt="two-sided") #For usual CI qqnorm(diff) # Summary graph layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(3,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(diff)[1]-sd(diff),range(diff)[2]+sd(diff)) hist(diff,xlim=plotrange, col = "pink",main="Pair-wise differences",ylab="") lines(density(diff),col="red",lwd=2) boxplot(diff, horizontal=TRUE, outline=TRUE,ylim=plotrange, frame=F, col = "green1", width = 10) #Clear graph dev.off()