R code from lecture notes for the Practical Machine Learning course on Coursera