For Coursera, R Programming, programming assignment 2