R code for data analysis