knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)
library(retention.helpers)
library(tidyverse)

Leveraging the grade helper functions

There are a series of useful functions with the prefix add_grade_*. The function add_grade_helpers adds all of these to any data frame with grade as a field:

some_sample_grades <- 
    tibble(grade = c("FL", "FNS", "PS", "PS", "HD", "GP", "ZZ"))

some_sample_grades |> 
    add_grade_helpers()

Note that grade_zf and grade_npe are identical. This is because sometimes we have used the term Zero-fail or Non-Participating Enrolment to indicate the same thing - a failing grade where the student also received a mark of 0 (FNS grade). To see how these are calculated refer to the table retention.helpers::grade_classifications.

If you only want a particular field appended to the data frame use add_grade_* instead:

some_sample_grades |> 
    add_grade_substantive() |> 
    add_grade_success()

For instance, you might want to count the grade distribution of only substantive (finalised and counting towards progress):

some_sample_grades |> 
    add_grade_helpers() |> 
    filter(grade_substantive) |> 
    count(grade)

Summarising grade data

The helpers can be used to calculate aggregates of grades, such as progress rates and GPA (using the gpa function).

some_sample_grades |> 
    add_grade_helpers() |> 
    summarise(
        progress_rate = sum(grade_success) / sum(grade_substantive),
        gpa = gpa(grade)
    )

Additionally, there is a function retention.helpers::summarise_academic() that aggregates a set of grades into two descriptions, result and result_long. This makes more sense to use with a grouped data frame.

tibble(
    student = c("A", "A", "A", "B", "B", "B"),
    grade = c("PS", "DI", "GP", "FNS", "FL", "PS")) |> 
    group_by(student) |> 
    summarise_academic()

# additionally, there is an option to include the list of (substantive) grades
tibble(
    student = c("A", "A", "A", "B", "B", "B"),
    grade = c("PS", "DI", "GP", "FNS", "FL", "PS")) |> 
    group_by(student) |> 
    summarise_academic(include_grades = TRUE)

Additional summary functions can be included, if used like a normal dplyr::summarise function. These can leverage any of the extra fields added from retention.helpers::add_grade_helpers.

tibble(
    student = c("A", "A", "A", "B", "B", "B"),
    grade = c("PS", "DI", "GP", "FNS", "FL", "PS")) |> 
    group_by(student) |> 
    summarise_academic(
        n_substantive_grades = sum(grade_substantive),
        progress_rate = sum(grade_success) / sum(grade_substantive)
    )


benwhicks/retention.helpers documentation built on Feb. 6, 2023, 5:02 p.m.