R code to perform the analysis