Update R code for Course Project