Coursera R Programming: assignment 2