Updated R functions

Completed R functions for assignment