r scripts for the analysis