Completed the R programming assignment 2