R code for bachelor's thesis