R code for creating the tidy dataset