My miscellaneous R functions