Fixed comments in code and changed the code in the write up to match actual R code