modified R code file for thrid week's homework