added comments/documentation to the code

Finalized the code for Programming Assignment 2 of Coursera’s
R-programming course.