Supplementary Information R code