Completed Assignment 2. Added test.R to provide sample of usage.