Coursera R programming assigment 2