The complete R code presented in Lesson 4 and Lesson 6 can be found here condensed into single files.