R Code that creates tidy dataset