solution for assignment 2 - R Programming (coursera)