R script to clean data