Updating Coursera Programming Assignment 2 R file