Programming assignment 2 from Coursera/R programming