Coursera R assignment 2