R code used for Assignment One