R code for getting and cleaning data