diff --git a/background_scripts/data_processing_func.R b/background_scripts/data_processing_func.R index 8aafe17..bd8de51 100644 --- a/background_scripts/data_processing_func.R +++ b/background_scripts/data_processing_func.R @@ -21,8 +21,9 @@ TM_data_prod_func <- function(sql_data, ReportYear) { mutate(SUBJ = sample(100:900, 1)) tm_data <- sql_data %>% + mutate(PRIOR_BAND = replace_na(PRIOR_BAND, "Unknown prior")) %>% filter( - !(is.na(PRIOR_BAND)), + # !(is.na(PRIOR_BAND)), !(is.na(SUBJ)) ) # %>% # bind_rows(tm_data_subj_na) @@ -33,6 +34,15 @@ TM_data_prod_func <- function(sql_data, ReportYear) { # ---- NUMBERS & PERCENTAGES CALCULATED ---- # ----------------------------------------------------------------------------------------------------------------------------- + totals <- tm_data %>% + group_by(Qual_Description, SUBLEVNO, Potential_Level, ASIZE, GSIZE, MAPPING, Subject, gradeStructure, SUBJ, GRADE) %>% + summarise(total_students = sum(total_students, na.rm = TRUE)) %>% + ungroup() %>% + mutate(PRIOR_BAND = "zAll") + + tm_data <- tm_data %>% + bind_rows(totals) + student_numbers <- tm_data %>% mutate( GRADE = case_when( @@ -46,6 +56,7 @@ TM_data_prod_func <- function(sql_data, ReportYear) { QUAL_ID = paste0(SUBLEVNO, SUBJ, SIZE, gradeStructure), ROW_ID = paste0(SUBLEVNO, SUBJ, SIZE, PRIOR_BAND, gradeStructure) ) %>% + mutate(PRIOR_BAND = if_else(PRIOR_BAND == "zAll", "All", PRIOR_BAND)) %>% mutate(across(c(everything(), -total_students), ~ as.character(.))) %>% arrange(ROW_ID, .locale = "en") %>% pivot_wider(names_from = GRADE, values_from = total_students) diff --git a/data/all_student_numbers.rds b/data/all_student_numbers.rds index 95290e4..7f2a4e8 100644 Binary files a/data/all_student_numbers.rds and b/data/all_student_numbers.rds differ diff --git a/data/all_student_percentages.rds b/data/all_student_percentages.rds index 3c151cd..1aed7a7 100644 Binary files a/data/all_student_percentages.rds and b/data/all_student_percentages.rds differ diff --git a/data/qual_lookup.rds b/data/qual_lookup.rds index 5f0ede4..f7478b7 100644 Binary files a/data/qual_lookup.rds and b/data/qual_lookup.rds differ diff --git a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001.json b/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001.json index a12e029..ff02242 100644 --- a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001.json +++ b/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001.json @@ -1,6 +1,6 @@ { "input": { - "ReportYr_select": "2023", + "ReportYr_select": "2024", "cookies": [ "GA1.1.1784488804.1728980230", "GS1.1.1729152208.1.1.1729152369.0.0.0" @@ -98,12 +98,12 @@ "TRUE" ], "format": "Numbers data", - "grade_structure_select": "*,A,B,C,D,E", + "grade_structure_select": "D,M", "link_to_app_content_tab": 0, "navlistPanel": "Homepage", - "qual_select": "GCE A level", - "size_select": "1", - "subj_select": "Accounting / Finance" + "qual_select": "Advanced Extension Award", + "size_select": "0", + "subj_select": "Mathematics" }, "output": { "example_table": { diff --git a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.new.png b/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.new.png deleted file mode 100644 index 3c902da..0000000 Binary files a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.new.png and /dev/null differ diff --git a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.png b/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.png index 2caf050..eca3225 100644 Binary files a/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.png and b/tests/testthat/_snaps/shinytest2/ks5-transition-matrices-001_.png differ