Structure demo code into an R package.

This PR is merely a refactoring with no functional change. It adds a package structure to the code with minimum viable documentation and a Travis config.
we need to add the apache license header to all the code files