A collection of useful R functions