R scirpt that creates the tidy data