My solution to R Programming Assignment 2