R code for Section 2
R code for Section 3
R code for Section 4