Calculate the average grade for a specified number of students and ranks them for a specific course or for the whole program completed thus far.

rank_students(df, courseid = "all", n = 4, ascending = FALSE)

Arguments

df

A dataframe containing the final grades for each student per course.

courseid

A string representing the course ID for which the ranking should be calculated for. Defaults to "all" for all courses completed thus far.

n

An integer value that represents the number of students for which the ranking is required for. Defaults to 3.

ascending

A logical value indicating whether the top or bottom ranking of students is required. Defaults to FALSE.

Value

A dataframe containing the rank of the students for the course or for all the program completed thus far.

Examples

df <- data.frame( course_id = c(rep("511", 4)), student_id = c("tom", "tiff", "mike", "joel"), grade = c(90, 80, 70, 67) ) rank_students(df = df)
#> student_id grade rank #> 1 tom 90 1 #> 2 tiff 80 2 #> 3 mike 70 3 #> 4 joel 67 4
rank_students(df = df, courseid = "511", n = 3, ascending = TRUE)
#> student_id grade rank #> 1 joel 67 4 #> 2 mike 70 3 #> 3 tiff 80 2