R script that runs sims and analyses output and creates figs in PDF file