R functions for various projects