Solution for programming assignment 2 of the coursera R programming course