Added code for chapter 8
Added R code for examples