R script for analyses and figures

R script including code needed to reproduce all key analyses in the paper, and to reproduce the figures. Comments included where explanation is necessary.