R functions for analyzing and computing grades