Program written for Assignment 2 in Coursera's R Programming course.