Useful shared R code