R code for data QA/QC