adding solution for Coursera R Programming assignment