R functions written and tested