Fanny's R code question 1 and 2.1