Assignment 2 R code completed