Coursera R Programming course exercise