R script for the analysis