Code for cleaning and subsetting data