adding R functions