useful R functions and scripts