First Assignment part 1, R version done