R code now working with grade 4 data