Skip to contents

@description [Maturing]

Usage

add_subject_context(d)

Arguments

d

data frame, as specified above

Details

Requires a data frame with the subject (six character code), n_remained (if this is NA the subject wasn't in HEPPP last year), genuine_pass_rate, n_passed, same_trigger (boolean) and also three fields describing when the subject runs, s1, s2 and s3. The sn fields should be set to internal, distance or both. If they are all blank (NA) then it is deemed that it is unknown when the subject is run next.

Examples

d <- tibble::tribble(
   ~subject, ~genuine_pass_rate, ~n_remained, ~n_passed, ~same_trigger, ~s1, ~s2, ~s3,
   "MEH111", NA_real_, NA, NA, NA, "both", "internal", "internal",
   "NUP200", 0.88, 18, 3, TRUE, NA_character_, "both", NA_character_,
   "LOL101", 0.71, 15, 0, FALSE, "distance", "distance", "distance"
)
d |> add_subject_context()
#> Error in dplyr::mutate(d, subject_context = stringr::str_c(subject, dplyr::if_else(!is.na(n_remained),     " was in last years campaign. ", " was not in last years campaign."),     dplyr::if_else(is.na(genuine_pass_rate), "", stringr::str_c(" Around ",         round(genuine_pass_rate/0.05) * 5, "% of students who submit at least 1 assessment end up passing.")),     dplyr::if_else(is.na(n_remained), "", dplyr::if_else(n_remained ==         0, "No students in a similar position last year remained past census date.",         stringr::str_c(" Last year ", n_remained, if_else(n_remained ==             1, " student", " students"), " who were in ", dplyr::if_else(same_trigger,             "the same", "a similar"), " position remained enrolled past census and ",             dplyr::if_else(n_passed == 0, "none of them passed.",                 stringr::str_c(n_passed, " of them passed (",                   round(100 * n_passed/n_remained), "%)."))))),     dplyr::if_else((is.na(s1) & is.na(s2) & is.na(s3)), "It is unclear when this subject is run next.",         stringr::str_c(" This subject runs in:", dplyr::case_when(is.na(s1) ~             "", s1 == "both" ~ " Session 1 (internal and distance)",             s1 == "internal" ~ " Session 1 (internal only)",             s1 == "distance" ~ " Session 1 (distance only)"),             dplyr::case_when(is.na(s2) ~ "", s2 == "both" ~ " Session 2 (internal and distance)",                 s2 == "internal" ~ " Session 2 (internal only)",                 s2 == "distance" ~ " Session 2 (distance only)"),             dplyr::case_when(is.na(s3) ~ "", s3 == "both" ~ " Session 3 (internal and distance)",                 s3 == "internal" ~ " Session 3 (internal only)",                 s3 == "distance" ~ " Session 3 (distance only)"))),     ".")): Problem while computing `subject_context = stringr::str_c(...)`.
#> Caused by error in `if_else()`:
#> ! could not find function "if_else"