R code for FE5217 HW4