Comments, Example, and Functional Code

I added extensive comments to this version, a working example, as well as the returned values from R from the example.