Initial implementation of R functions