Solution to Programming Assignment 3 from Coursera "R Programming"