R program for Coursera assignment 2

Details of the implementation in the code