final R script to create tidy data