My homework assignment 2 in R programming on coursera