added R code for rprog assignment 2