Added more comments to the code in the Lab4.Rnw file for readability