Finished version of R programming assignment 2