R Project - first draft of answer

Completed two functions. Tested with test cases. Need to document and
test some more.