.R file for grading