my solution for assignment 2 of the coursera course R programming