R code for coursera classes