Coursera R programming assignment 2