R script to generate a tidy data set