R code for HW1