Coursera course R Programming - Programming assignment 2