R script for getting the tidy data