A bunch of useful miscellaneous R functions