Code for Assignment 2 of R programming course on Coursera