R code for MSc thesis research