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.
Done.