Code for programming assignment 2 of coursera r programming course.