R script to run analysis