R script to create tidy data set