Changed R file to use PivotalR