Dependencies

This document depends on the following packages:

  library(devtools)
  library(Biobase)
  library(UsingR)

To install these packages you can use the code (or if you are compiling the document, remove the eval=FALSE from the chunk.)

install.packages(c("devtools","UsingR"))
source("http://www.bioconductor.org/biocLite.R")
biocLite(c("Biobase"))

Load Galton Data

data(galton)
par(mfrow=c(1,2))
hist(galton$child,col="blue",breaks=100)
hist(galton$parent,col="blue",breaks=100)

The distribution of child heights

hist(galton$child,col="blue",breaks=100)

Only know the child - average height

hist(galton$child,col="blue",breaks=100)
meanChild <- mean(galton$child)
lines(rep(meanChild,100),seq(0,150,length=100),col="red",lwd=5)

What if we plot child versus average parent

plot(galton$parent,galton$child,pch=19,col="blue")

Average parent = 65 inches tall

plot(galton$parent,galton$child,pch=19,col="blue")
near65 <- galton[abs(galton$parent - 65)<1, ]
points(near65$parent,near65$child,pch=19,col="red")
lines(seq(64,66,length=100),rep(mean(near65$child),100),col="red",lwd=4)

Average parent = 71 inches tall

plot(galton$parent,galton$child,pch=19,col="blue")
near71 <- galton[abs(galton$parent - 71)<1, ]
points(near71$parent,near71$child,pch=19,col="red")
lines(seq(70,72,length=100),rep(mean(near71$child),100),col="red",lwd=4)