R code for Project 1