Handy R functions and scripts