diff --git a/.gitignore b/.gitignore index 4ea95b9..a05ad96 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,8 @@ .Rhistory .RData .Ruserdata -.data/aps_gender_gap_with_2024 -.data/all_alevel_timeseries_data_1996_to_2024.csv -.data/maths_science_2010_2024.csv -.data/all_attainment_with_2024_redacted.csv -.data/alevel_attainment_with_2024.csv \ No newline at end of file +data/aps_gender_gap_with_2024.csv +data/all_alevel_timeseries_data_1996_to_2024.csv +data/maths_science_2010_2024.csv +data/all_attainment_with_2024_redacted.csv +data/alevel_attainment_with_2024.csv \ No newline at end of file diff --git a/R/dashboard_panels.R b/R/dashboard_panels.R index c3f3f35..07f0a8e 100644 --- a/R/dashboard_panels.R +++ b/R/dashboard_panels.R @@ -1,6 +1,12 @@ homepage_panel <- function() { tabPanel( "Homepage", + modalDialog( + title = "Missing data", + "The headline attainment does not include vocational and technical qualifications for 2024 provisional data due to a data collection issue. This will be resolved in the revised publication.", + size = "l", + easyClose = FALSE + ), gov_main_layout( gov_row( column( @@ -10,6 +16,7 @@ homepage_panel <- function() { br() ), + ## Left panel ------------------------------------------------------- column( @@ -33,31 +40,31 @@ homepage_panel <- function() { tags$div( title = "Headline attainment and A level time series by institution type", h3(actionLink("link_to_headline_tab", "Headline attainment and A level result by institution type")), - p("The headline boxes show the latest average result for A level, applied general and tech level qualifications for all students. The chart shows the yearly trend from 2015/16 to 2022/23. "), - p("The year in tables/charts is the academic year in which students completed 16-18 study (i.e. 2023 means 2022/23). 16-18 study normally lasts either 2 or 3 years and attainment accounts for all entries during that period."), + p(" The headline attainment does not include vocational and technical qualifications for 2024 provisional data due to a data collection issue. This will be resolved in the revised publication."), + p("The year in tables/charts is the academic year in which students completed 16-18 study (i.e. 2024 means 2023/24). 16-18 study normally lasts either 2 or 3 years and attainment accounts for all entries during that period."), p("Drop-down box within the chart area allows for selection of one institution type. To view latest results and trend, click on the drop-down box and select institution type required."), - h4("APS for A level by all & gender"), - p("The line charts display the yearly trend and grades for all students and by gender, while the female - male gender gap shows the difference in average point score. + h4("APS for A level by all & sex"), + p("The line charts display the yearly trend and grades for all students and by sex, while the female - male sex gap shows the difference in average point score. To view and explore trend select up to four institution types from the drop-down menu at the top of the page."), tags$div( - title = "(A level students entering maths and science by gender", - h3(actionLink("link_to_alevelMathsScience_tab", "A level students entering maths and science by gender")), - p("The line chart shows the yearly trend in the proportion of A level students entering maths and science from 2009/10 to 2022/23 (end of 16-18 study). + title = "(A level students entering maths and science by sex", + h3(actionLink("link_to_alevelMathsScience_tab", "A level students entering maths and science by sex")), + p("The line chart shows the yearly trend in the proportion of A level students entering maths and science from 2009/10 to 2023/24 (end of 16-18 study). Select one subject or combination from the dropdown menu at the top of the page, followed by the start year to view changes over time (end year is fixed at the latest year available).") ), tags$div( title = "(A level subject entry and grade: comparison by subject", h3(actionLink("link_to_alevelAllSubject_tab", "A level subject entry and grade: comparison by subject")), - p("The line charts for subject entries and cumulative percentage grades display the yearly trend from 1995/96 to 2022/23. + p("The line charts for subject entries and cumulative percentage grades display the yearly trend from 1995/96 to 2023/24. Drop-down menus at the top of the page allows for the selection and comparison of up to four subjects and cumulative grades. "), - p("The data refers to all entries by 16-18 year olds in the year stated (where 2023 means 2022/23 academic year).") + p("The data refers to all entries by 16-18 year olds in the year stated (where 2024 means 2023/24 academic year).") ), tags$div( - title = "A level subject entry and result: comparison by gender", - h3(actionLink("link_to_alevelFmSubject_tab", "A level subject entry and result: comparison by gender")), - p("The line charts for subject entries and cumulative percentage grades display the yearly trend for female and male from 1995/96 to 2022/23. + title = "A level subject entry and result: comparison by sex", + h3(actionLink("link_to_alevelFmSubject_tab", "A level subject entry and result: comparison by sex")), + p("The line charts for subject entries and cumulative percentage grades display the yearly trend for female and male from 1995/96 to 2023/24. Select one subject from the dropdown menu at the top of the page, followed by the start year to view changes over time (end year is fixed at the latest year available)."), p(""), br(), @@ -116,7 +123,7 @@ homepage_panel <- function() { title = "A level subject entry and cumulative grade", h3("A level subject entry and cumulative grade"), p("The subject entries and cumulative grades covered on the dashboard are based on - subjects grouped from 1995/96 to 2022/23. More detailed breakdowns of some subjects from 2015/16 + subjects grouped from 1995/96 to 2023/24. More detailed breakdowns of some subjects from 2015/16 are available via the full dataset download button at the top of the page."), h4("Subject definitions"), p("Total English covers English literature, English language, English language and literature. "), @@ -125,7 +132,7 @@ homepage_panel <- function() { p("Total Classical studies covers Latin, Greek, Classical civilisation, and Other classical studies"), p("STEM subjects cover Biology, Chemistry, Physics, Total maths, Further mathematics and Computer science. "), p("Total Music includes Music and Music technology."), - p("The data refers to all entries by 16-18 year olds in the year stated (where 2023 means 2022/23 academic year).") + p("The data refers to all entries by 16-18 year olds in the year stated (where 2024 means 2023/24 academic year).") ) ) ) @@ -163,9 +170,9 @@ dashboard_panel_aps <- function() { column( width = 3, selectizeInput( - inputId = "allGender", + inputId = "allSex", label = "Select students", - choices = unique(dfAlevelAps$characteristic_gender) %>% + choices = unique(dfAlevelAps$characteristic_sex) %>% sort(), selected = "All students" ) ), @@ -174,7 +181,7 @@ dashboard_panel_aps <- function() { selectizeInput("alevelInstitute", "Select up to 4 institution types", choices = list( `Institution types` = c( - "All Institutions", "All FE sector colleges", "All independent schools", "All schools", "All state-funded", + "All institutions", "All FE sector colleges", "All independent schools", "All schools", "All state-funded", "All state-funded schools" ), `All FE sector colleges` = c("Other FE sector colleges", "Sixth form colleges"), @@ -207,7 +214,7 @@ dashboard_panel_aps <- function() { inputId = "ees_1", label = "Visit Explore Education Statistics", icon = icon("table-cells"), - onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2022-23', '_blank')", + onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2023-24', '_blank')", style = "width:100%;white-space:normal;" ) ), @@ -231,14 +238,14 @@ dashboard_panel_aps <- function() { fluidRow( column( width = 12, - h3(" 2023 Average results and time series for level 3 attainment, all students"), + h3(" 2024 Average results and time series for level 3 attainment, all students"), fluidRow( - valueBoxOutput("headBox1", width = 4), - bsTooltip("headBox1", "Average result - A level", placement = "top", trigger = "hover", options = NULL), - valueBoxOutput("headBox2", width = 4), - bsTooltip("headBox2", "Average result - Applied general", placement = "top", trigger = "hover", options = NULL), - valueBoxOutput("headBox3", width = 4), - bsTooltip("headBox3", "Average result - Tech Level", placement = "top", trigger = "hover", options = NULL) + valueBoxOutput("headBox1", width = 12), + bsTooltip("headBox1", "Average result - A level", placement = "top", trigger = "hover", options = NULL) + # valueBoxOutput("headBox2", width = 4), + # bsTooltip("headBox2", "Average result - Applied general", placement = "top", trigger = "hover", options = NULL), + # valueBoxOutput("headBox3", width = 4), + # bsTooltip("headBox3", "Average result - Tech Level", placement = "top", trigger = "hover", options = NULL) ), column( width = 9, textOutput("textHeadline") @@ -254,7 +261,7 @@ dashboard_panel_aps <- function() { selectInput( inputId = "headlineAps", "Select institution type", - choices = sort(unique(dfAttainment$school_type)), selected = c("All Institutions") + choices = sort(unique(dfAttainment$establishment_type)), selected = c("All Institutions") ) ) ) @@ -300,12 +307,12 @@ dashboard_panel_aps <- function() { # ), tabPanel( - "A level APS gender gap", + "A level APS sex gap", value = "ggap", fluidRow( column( width = 12, - h3("A level female - male average points difference by institution type from 2015/16 to 2022/23 in England"), + h3("A level female - male average points difference by institution type from 2015/16 to 2023/24 in England"), textOutput("textGgap"), # htmlOutput("boxapsAlevel", width = 2), @@ -317,7 +324,7 @@ dashboard_panel_aps <- function() { ) ), tabPanel( - "A level APS by gender", + "A level APS by sex", value = "alevel_fm", fluidRow( column( @@ -386,7 +393,7 @@ dashboard_panel_sub_all <- function() { gov_row( column( width = 12, - h2("A level single entry and grade distribution: Comparison by subject, England from 1995/96 to 2022/23") + h2("A level single entry and grade distribution: Comparison by subject, England from 1995/96 to 2023/24") ), column( width = 12, @@ -399,7 +406,7 @@ dashboard_panel_sub_all <- function() { selectInput( inputId = "subByAll", label = "Select students", - choices = unique(subjectByAll$characteristic_gender) %>% + choices = unique(subjectByAll$characteristic_value) %>% sort(), selected = "All students" ) ), @@ -450,7 +457,7 @@ dashboard_panel_sub_all <- function() { inputId = "ees_2a", label = "Visit Explore Education Statistics", icon = icon("table-cells"), - onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2022-23', '_blank')", + onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2023-24', '_blank')", style = "width:100%;white-space:normal;" ) ), @@ -575,7 +582,7 @@ dashboard_panel_sub_all <- function() { dashboard_panel_sub_fm <- function() { tabPanel( value = "dashboard_fm", - "A level subject entry & result: comparison by gender (single academic year)", + "A level subject entry & result: comparison by sex (single academic year)", # Define UI for application that draws a histogram @@ -585,7 +592,7 @@ dashboard_panel_sub_fm <- function() { gov_row( column( width = 12, - h2("A level subject entry and grade distribution: comparison by gender, England from 1995/96 to 2022/23") + h2("A level subject entry and grade distribution: comparison by sex, England from 1995/96 to 2023/24") ), column( width = 12, @@ -597,7 +604,7 @@ dashboard_panel_sub_fm <- function() { width = 6, selectizeInput( inputId = "subjectFm", label = "Select a subject:", - choices = sort(unique(subjectByGender$subject_name)), + choices = sort(unique(subjectBySex$subject_name)), multiple = F, selected = c("Total English") ) @@ -638,7 +645,7 @@ dashboard_panel_sub_fm <- function() { inputId = "ees_2b", label = "Visit Explore Education Statistics", icon = icon("table-cells"), - onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2022-23', '_blank')", + onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2023-24', '_blank')", style = "width:100%;white-space:normal;" ) ), @@ -657,11 +664,11 @@ dashboard_panel_sub_fm <- function() { id = "tabsetpanels2b", tabPanel( value = "alevelFmSubject", - "Subject entries by gender", + "Subject entries by sex", fluidRow( column( width = 12, - h3("A level subject: Comparison by gender"), + h3("A level subject: Comparison by sex"), textOutput("textSubFm"), br(), column( width = 6, @@ -690,11 +697,11 @@ dashboard_panel_sub_fm <- function() { ) ), tabPanel( - "Cumulative results by gender", + "Cumulative results by sex", fluidRow( column( width = 9, - h3("A level cumulative percentage grade by subject and gender"), + h3("A level cumulative percentage grade by subject and sex"), textOutput("textResFm") ), column( @@ -759,7 +766,7 @@ dashboard_panel_sub_fm <- function() { dashboard_panel_ms <- function() { tabPanel( value = "dashboard_ms", - "A level maths & science: comparison by gender (end of 16-18 study)", + "A level maths & science: comparison by sex (end of 16-18 study)", # Define UI for application that draws a histogram @@ -768,7 +775,7 @@ dashboard_panel_ms <- function() { gov_row( column( width = 12, - h2("A level maths and science entry (end of 16 to 18 study): comparison by gender, England from 2009/10 to 2022/23") + h2("A level maths and science entry (end of 16 to 18 study): comparison by sex, England from 2009/10 to 2023/24") ), column( width = 12, @@ -827,7 +834,7 @@ dashboard_panel_ms <- function() { inputId = "ees_3", label = "Visit Explore Education Statistics", icon = icon("table-cells"), - onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2022-23', '_blank')", + onclick = "window.open('https://explore-education-statistics.service.gov.uk/find-statistics/a-level-and-other-16-to-18-results/2023-24', '_blank')", style = "width:100%;white-space:normal;" ) ), @@ -851,7 +858,7 @@ dashboard_panel_ms <- function() { fluidRow( column( width = 12, - h3("A level maths and science: Comparison by gender"), + h3("A level maths and science: Comparison by sex"), textOutput("textSubMs"), br() ), box( @@ -864,10 +871,10 @@ dashboard_panel_ms <- function() { fluidRow( column(width = 12), p("Note: The number of students from 2009/10 to 2017/18 has been calculated from rounded data, so less precise than the number of students from - 2018/19 to 2022/23") + 2018/19 to 2023/24") ) ), - dataTableOutput("tabMs"), + dataTableOutput("tabMs") ) ) ) diff --git a/R/plotting.R b/R/plotting.R index 4fb08df..06fe29f 100644 --- a/R/plotting.R +++ b/R/plotting.R @@ -17,7 +17,7 @@ createTimeSeriesHeadline <- function(dfAps, allAps) { # scale_x_log10(breaks = seq(2016, 2023, 2)) + labs(x = "", y = "", color = "") + coord_cartesian(ylim = c(0, 60)) + - scale_x_continuous(breaks = seq(2016, 2023, 1)) + + scale_x_continuous(breaks = seq(2016, 2024, 1)) + theme_classic() + theme( legend.position = "", @@ -53,14 +53,14 @@ createTimeSeriesHeadline <- function(dfAps, allAps) { # Joint plot function for Alevel Aps from 2013 -createApsTimeSeries <- function(dfAps, instGroup, instType, allGender) { - validate(need(dfAps$school_type, message = "To view charts select type of students and up to 4 institution types from the drop-down menus at the top page")) +createApsTimeSeries <- function(dfAps, instGroup, instType, allSex) { + validate(need(dfAps$establishment_type, message = "To view charts select type of students and up to 4 institution types from the drop-down menus at the top page")) fig2 <- dfAps %>% filter(year >= 2016) - fig1 <- ggplot(dfAps, aes(x = year_2013_2015, y = aps_2013_2015, color = school_type)) + + fig1 <- ggplot(dfAps, aes(x = year_2013_2015, y = aps_2013_2015, color = establishment_type)) + geom_line(stat = "identity", linewidth = 1.5) + geom_curve(aes(x = 2015.5, y = 50, xend = 2015, yend = 45), arrow = arrow(length = unit(0.03, "npc"), type = "closed"), @@ -73,7 +73,7 @@ createApsTimeSeries <- function(dfAps, instGroup, instType, allGender) { scale_x_continuous(breaks = seq(2013, 2015, 1)) + scale_colour_manual( "", - breaks = unique(dfAps$school_type), + breaks = unique(dfAps$establishment_type), values = gss_colour_pallette ) + theme_classic() + @@ -88,7 +88,7 @@ createApsTimeSeries <- function(dfAps, instGroup, instType, allGender) { ) - fig2 <- ggplot(fig2, aes(x = year, y = aps_2016_2023, color = school_type)) + + fig2 <- ggplot(fig2, aes(x = year, y = aps_2016_2024, color = establishment_type)) + geom_line(stat = "identity", linewidth = 1.5) + geom_curve(aes(x = 2016.5, y = 48, xend = 2016, yend = 45), curvature = .3, @@ -105,14 +105,14 @@ createApsTimeSeries <- function(dfAps, instGroup, instType, allGender) { arrow = arrow(length = unit(0.03, "npc"), type = "closed"), color = "black", size = .05, angle = 90 ) + - geom_label(aes(label = aps_grade_2016_2023, y = aps_2016_2023), show.legend = F) + - ggtitle(paste0("\n APS & grade 2015/16 to 2022/23: ", allGender)) + + geom_label(aes(label = aps_grade_2016_2024, y = aps_2016_2024), show.legend = F) + + ggtitle(paste0("\n APS & grade 2015/16 to 2023/24: ", allSex)) + coord_cartesian(ylim = c(10, 60)) + scale_y_continuous(limits = c(10, 60)) + - scale_x_continuous(breaks = seq(2016, 2023, 1)) + + scale_x_continuous(breaks = seq(2016, 2024, 1)) + scale_colour_manual( "", - breaks = unique(dfAps$school_type), + breaks = unique(dfAps$establishment_type), values = gss_colour_pallette ) + labs(x = "", y = "", color = "") + @@ -133,21 +133,21 @@ createApsTimeSeries <- function(dfAps, instGroup, instType, allGender) { ) finalFig <- (fig1 + fig2 + plot_layout(widths = c(0.7, 2)) & - ggtitle(paste0("APS and grade \n", allGender))) + ggtitle(paste0("APS and grade \n", allSex))) return(finalFig) } -################################################## Plot function for APS by gender and gender gap ################################## +################################################## Plot function for APS by sex and sex gap ################################## -createApsFmTimeSeries <- function(dfApsFm, instGroup, instType, fmGender) { - validate(need(dfApsFm$school_type, message = "To view chart select between 1 and 4 institution types from the drop-down menu at the top page.")) +createApsFmTimeSeries <- function(dfApsFm, instGroup, instType, fmSex) { + validate(need(dfApsFm$establishment_type, message = "To view chart select between 1 and 4 institution types from the drop-down menu at the top page.")) fmFig <- ggplot(dfApsFm, aes( - x = year, y = aps_2016_2023, - color = school_type + x = year, y = aps_2016_2024, + color = establishment_type )) + geom_line(stat = "identity", linewidth = 1.5) + geom_curve(aes(x = 2019.5, y = 53, xend = 2020, yend = 50), @@ -160,13 +160,13 @@ createApsFmTimeSeries <- function(dfApsFm, instGroup, instType, fmGender) { arrow = arrow(length = unit(0.03, "npc"), type = "closed"), color = "black", size = .05, angle = 90 ) + - geom_label(aes(label = aps_grade_2016_2023, y = aps_2016_2023), show.legend = F) + - ggtitle(paste0("Average point score and grade: ", fmGender)) + + geom_label(aes(label = aps_grade_2016_2024, y = aps_2016_2024), show.legend = F) + + ggtitle(paste0("Average point score and grade: ", fmSex)) + coord_cartesian(ylim = c(10, 60)) + - scale_x_continuous(breaks = seq(2016, 2023, 1)) + + scale_x_continuous(breaks = seq(2016, 2024, 1)) + scale_colour_manual( - # "school type", - breaks = unique(dfApsFm$school_type), + # "establishment type", + breaks = unique(dfApsFm$establishment_type), values = gss_colour_pallette ) + labs(x = "", y = "", color = "") + @@ -191,28 +191,28 @@ createApsFmTimeSeries <- function(dfApsFm, instGroup, instType, fmGender) { -createGenderGap <- function(dfApsGap, instGroup, instType) { - validate(need(dfApsGap$school_type, message = "To view chart select between 1 and 4 institution types from the drop-down menu at the top page.")) +createSexGap <- function(dfApsGap, instGroup, instType) { + validate(need(dfApsGap$establishment_type, message = "To view chart select between 1 and 4 institution types from the drop-down menu at the top page.")) fig <- dfApsGap %>% - rename(Year = "year", Gender_gap = "gender_gap", Institution_type = "school_type") + rename(Year = "year", Sex_gap = "sex_gap", Institution_type = "establishment_type") fig <- ggplot(fig, aes( x = Year, - y = Gender_gap, + y = Sex_gap, color = Institution_type )) + geom_line(stat = "identity", linewidth = 1) + - scale_x_continuous(breaks = seq(2016, 2023, 1)) + + scale_x_continuous(breaks = seq(2016, 2024, 1)) + scale_y_continuous(labels = scales::comma) + scale_colour_manual( - # "school type", - # breaks = unique(dfApsGap$school_type), + # "establishment type", + # breaks = unique(dfApsGap$establishment_type), values = gss_colour_pallette ) + labs(x = "", y = "", color = "") + geom_hline(yintercept = 0, linetype = "dot", col = "navy") + - ggtitle(paste0("\nFemale-male average points difference (gender gap)")) + + ggtitle(paste0("\nFemale-male average points difference (Sex gap)")) + theme_classic() + theme( # legend.position ="bottom", text = element_text(size = 12), @@ -260,7 +260,7 @@ createTimeSeriesSubject <- function(dfSubjectA, subAll, subName) { geom_line(stat = "identity", linewidth = 1) + # geom_point(stat="identity", size=1.5, show.legend=F)+ - scale_x_log10(breaks = seq(1996, 2023, 2)) + + scale_x_log10(breaks = seq(1996, 2024, 2)) + scale_y_continuous(labels = scales::comma) + scale_colour_manual( values = gss_colour_pallette @@ -308,7 +308,7 @@ createTimeSeriesResult <- function(dfSubjectA, subAll, resAll, subName) { fig <- ggplot(fig, aes_string(x = "Year", y = resAll, color = "Subject")) + geom_line(stat = "identity", linewidth = 1, show.legend = F) + # geom_point(stat= "identity", size=1.5, show.legend=F)+ - scale_x_log10(breaks = seq(1996, 2023, 2)) + + scale_x_log10(breaks = seq(1996, 2024, 2)) + scale_y_continuous(labels = scales::comma) + scale_colour_manual( # breaks = unique(dfSubjectA$Subject), @@ -347,26 +347,26 @@ createTimeSeriesResult <- function(dfSubjectA, subAll, resAll, subName) { -############################################# Plot for subject entries and results A level gender ##################################################### +############################################# Plot for subject entries and results A level sex ##################################################### createTimeSeriesSubjectFm <- function(dfSubjectG, subByFm) { validate(need(dfSubjectG$subject_name, message = "To view chart select one subject and a start year from the drop-down menus at the top of the page.")) fig <- dfSubjectG %>% - rename(Year = "year", Entry_count = "entry_count", Subject = "subject_name", Gender = "characteristic_gender") + rename(Year = "year", Entry_count = "entry_count", Subject = "subject_name", Sex = "characteristic_value") fig <- ggplot( fig, aes( x = Year, y = Entry_count, - color = Gender + color = Sex ) ) + geom_line(stat = "identity", linewidth = 1) + # geom_point(size=1.5)+ - scale_x_log10(breaks = seq(1996, 2023, 2)) + + scale_x_log10(breaks = seq(1996, 2024, 2)) + scale_y_continuous(labels = scales::comma) + scale_color_manual( - # breaks = (dfSubjectG$charateristic_gender), + # breaks = (dfSubjectG$charateristic_sex), values = c("#3D3D3D", "#F46A25", "#12436D") ) + labs(x = "", y = "", color = "") + @@ -404,13 +404,13 @@ createTimeSeriesSubjectFm <- function(dfSubjectG, subByFm) { createTimeSeriesResultFm <- function(dfSubjectG, subByFm, resByFm) { validate(need(dfSubjectG$subject_name, message = " To view chart select one subject and a start year from the drop-down menus and finally select cumulative grade")) fig <- dfSubjectG %>% - rename(Year = "year", Subject = "subject_name", Gender = "characteristic_gender") + rename(Year = "year", Subject = "subject_name", Sex = "characteristic_value") - fig <- ggplot(fig, aes_string("Year", y = resByFm, color = "Gender")) + + fig <- ggplot(fig, aes_string("Year", y = resByFm, color = "Sex")) + geom_line(stat = "identity", linewidth = 1) + # geom_point(size=1.5)+ scale_color_manual(values = c("#3D3D3D", "#F46A25", "#12436D")) + - scale_x_log10(breaks = seq(1996, 2023, 2)) + + scale_x_log10(breaks = seq(1996, 2024, 2)) + labs(x = "", y = "", color = "") + theme_classic() + annotate("rect", xmin = 2020, xmax = 2021, ymin = 5, ymax = 100, alpha = .2) + @@ -448,19 +448,19 @@ createTimeSeriesSubjectMs <- function(dfSubjectMs, subByMs) { fig <- dfSubjectMs %>% - rename(Year = "year", Percent = "percent_entered", Subject = "subject", Gender = "characteristic_gender") + rename(Year = "year", Percent = "percent_entered", Subject = "subject", Sex = "characteristic_value") fig <- ggplot( fig, aes( x = Year, y = Percent, - color = Gender + color = Sex ) ) + geom_line(stat = "identity", linewidth = 1) + # geom_point(size=1.5)+ - scale_x_log10(breaks = seq(2010, 2023, 1)) + + scale_x_log10(breaks = seq(2010, 2024, 1)) + scale_y_continuous(labels = scales::comma) + scale_color_manual( - # breaks = (dfSubjectG$charateristic_gender), + # breaks = (dfSubjectG$charateristic_sex), values = c("#3D3D3D", "#F46A25", "#12436D") ) + labs(x = "", y = "", color = "") + diff --git a/R/read_data.R b/R/read_data.R index c92883b..0c2b226 100644 --- a/R/read_data.R +++ b/R/read_data.R @@ -20,7 +20,7 @@ # Select the columns to be used # Filter out total subjects -read_alevel_subject_data <- function(file = "data/all_alevel_timeseries_data_1996_to_2023rev.csv") { +read_alevel_subject_data <- function(file = "data/all_alevel_timeseries_data_1996_to_2024.csv") { dfSubject <- read_csv(file, show_col_types = FALSE) dfSubject <- dfSubject @@ -28,7 +28,7 @@ read_alevel_subject_data <- function(file = "data/all_alevel_timeseries_data_199 } # This data is for Aggregate A level APS and grade by institution type -read_alevel_aps_data <- function(file = "data/alevel_attainment_with_rev2023.csv") { +read_alevel_aps_data <- function(file = "data/alevel_attainment_with_2024.csv") { dfAlevelAps <- read_csv(file, show_col_types = FALSE) dfAlevelAps <- dfAlevelAps @@ -36,7 +36,7 @@ read_alevel_aps_data <- function(file = "data/alevel_attainment_with_rev2023.csv } # This data is for A level APS gender gap by institution type -read_alevel_aps_gendergap_data <- function(file = "data/aps_gender_gap_with_rev2023.csv") { +read_alevel_aps_sexgap_data <- function(file = "data/aps_gender_gap_with_2024.csv") { dfApsGenderGap <- read_csv(file, show_col_types = FALSE) dfApsGenderGap <- dfApsGenderGap @@ -45,14 +45,14 @@ read_alevel_aps_gendergap_data <- function(file = "data/aps_gender_gap_with_rev2 # This is the full attainment dataset comprising of Alevel, applied general and tech level -read_all_attainment_data <- function(file = "data/all_attainment_with_rev2023.csv") { +read_all_attainment_data <- function(file = "data/all_attainment_with_2024_redacted.csv") { dfAttainment <- read_csv(file, show_col_types = FALSE) dfAttainment <- dfAttainment return(dfAttainment) } -read_all_ms_data <- function(file = "data/maths_science_2010_2023rev.csv") { +read_all_ms_data <- function(file = "data/maths_science_2010_2024.csv") { dfMsRaw <- read_csv(file, show_col_types = FALSE) dfMsRaw <- dfMsRaw } diff --git a/global.R b/global.R index 5805dcc..0d003b6 100644 --- a/global.R +++ b/global.R @@ -11,7 +11,7 @@ # Library calls --------------------------------------------------------------------------------- shhh <- suppressPackageStartupMessages # It's a library, so shhh! shhh(library(shiny)) -#shhh(library(shinya11y)) +# shhh(library(shinya11y)) shhh(library(shinyjs)) # shhh(library(tools)) shhh(library(testthat)) @@ -76,6 +76,7 @@ spinner <- function(output) { + # Source scripts --------------------------------------------------------------------------------- # Source any scripts here. Scripts may be needed to process data before it gets to the server file. @@ -116,7 +117,7 @@ source("R/read_data.R") # Create new column for thousand entries -latest_year <- 2024 # this is mainly used by A level subject entries and Maths and Science to allow selection of year +latest_year <- 2024 # this is mainly used by A level subject entries and Maths and Science to allow selection of year dfAlevelSubjectRaw <- read_alevel_subject_data() @@ -190,7 +191,7 @@ dfAlevelAps <- data %>% establishment_type_group = as.factor(establishment_type_group), version = as.factor(version), establishment_type = as.factor(recode(establishment_type, - # "All schools and FE sector colleges" = "All institutions", + # "All schools and FE sector colleges" = "All institutions", "All state-funded schools and colleges" = "All state-funded" )) ) @@ -205,12 +206,12 @@ dfAlevelAps <- data %>% # Use data from 2015/16 -dfApsSexGap <- read_alevel_aps_sexgap_data() +dfApsSexGap <- read_alevel_aps_sexgap_data() fmDiff <- dfApsSexGap %>% mutate( sex_gap = round(as.numeric(sex_gap), 1), establishment_type = as.factor(recode(establishment_type, - # "All schools and FE sector colleges" = "All institutions", + # "All schools and FE sector colleges" = "All institutions", "All state-funded schools and colleges" = "All state-funded" )) ) @@ -238,7 +239,7 @@ dfAttainment <- dfAttainmentRaw %>% version = as.factor(version), cert_type = as.factor(cert_type), establishment_type = as.factor(recode(establishment_type, - #"All schools and FE sector colleges" = "All Institutions", + # "All schools and FE sector colleges" = "All Institutions", "All state-funded schools and colleges" = "All state-funded" )), cert_type = as.factor(recode(cert_type, "Alevel" = "A level")) diff --git a/server.R b/server.R index 9cab2bd..6d8bd8b 100644 --- a/server.R +++ b/server.R @@ -47,7 +47,7 @@ server <- function(input, output, session) { paste0( # site_title, " - ", input$alevelInstitute, ", ", - input$allGender + input$allSex ) ) } else { @@ -157,7 +157,7 @@ server <- function(input, output, session) { reactiveHeadline <- reactive({ headlineData <- dfAttainment %>% filter( - school_type == input$headlineAps + establishment_type == input$headlineAps ) }) @@ -179,9 +179,9 @@ server <- function(input, output, session) { # Add value box for A level output$headBox1 <- renderValueBox({ latest <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "A level", school_type == input$headlineAps))$aps + filter(year == max(year), cert_type == "A level", establishment_type == input$headlineAps))$aps grade <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "A level", school_type == input$headlineAps))$aps_grade + filter(year == max(year), cert_type == "A level", establishment_type == input$headlineAps))$aps_grade valueBox( value = grade, subtitle = paste0("Average A level result equivalent to ", latest, " points: ", input$headlineAps), # width = 12, @@ -189,33 +189,33 @@ server <- function(input, output, session) { ) }) - - # Add value box for Applied general - output$headBox2 <- renderValueBox({ - latest <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "Applied general", school_type == input$headlineAps))$aps - # result <- "Average applied general result" - grade <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "Applied general", school_type == input$headlineAps))$aps_grade - valueBox( - value = grade, subtitle = paste0("Average applied general result equivalent to ", latest, " points: ", input$headlineAps), - color = "blue" - ) - }) - - - # Add Value box for Tech level - - output$headBox3 <- renderValueBox({ - latest <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "Tech level", school_type == input$headlineAps))$aps - grade <- (reactiveHeadline() %>% - filter(year == max(year), cert_type == "Tech level", school_type == input$headlineAps))$aps_grade - valueBox( - value = grade, subtitle = paste0("Average tech level result equivalent to ", latest, " points: ", input$headlineAps), - color = "blue" - ) - }) + # + # # Add value box for Applied general + # output$headBox2 <- renderValueBox({ + # latest <- (reactiveHeadline() %>% + # filter(year == max(year), cert_type == "Applied general", establishment_type == input$headlineAps))$aps + # # result <- "Average applied general result" + # grade <- (reactiveHeadline() %>% + # filter(year == max(year), cert_type == "Applied general", establishment_type == input$headlineAps))$aps_grade + # valueBox( + # value = grade, subtitle = paste0("Average applied general result equivalent to ", latest, " points: ", input$headlineAps), + # color = "blue" + # ) + # }) + # + # + # # Add Value box for Tech level + # + # output$headBox3 <- renderValueBox({ + # latest <- (reactiveHeadline() %>% + # filter(year == max(year), cert_type == "Tech level", establishment_type == input$headlineAps))$aps + # grade <- (reactiveHeadline() %>% + # filter(year == max(year), cert_type == "Tech level", establishment_type == input$headlineAps))$aps_grade + # valueBox( + # value = grade, subtitle = paste0("Average tech level result equivalent to ", latest, " points: ", input$headlineAps), + # color = "blue" + # ) + # }) # Create reactive for Headline data @@ -223,12 +223,12 @@ server <- function(input, output, session) { headlineData <- dfAttainment headlineData <- subset( headlineData, - school_type == input$headlineAps + establishment_type == input$headlineAps ) %>% select( Year = year, `Academic year` = time_period, - `Institution type` = school_type, + `Institution type` = establishment_type, `Number of students` = number_of_students, `APS per entry` = aps, `APS per entry grade` = aps_grade, @@ -274,9 +274,9 @@ server <- function(input, output, session) { observe({ validate(need(!is.null(input$tabsetpanels), "")) if (input$tabsetpanels == "headline") { - hide("allGender") + hide("allSex") } else { - show("allGender") + show("allSex") } }) @@ -292,9 +292,9 @@ server <- function(input, output, session) { observe({ validate(need(!is.null(input$tabsetpanels), "")) if (input$tabsetpanels == "alevel_fm" || input$tabsetpanels == "ggap") { - disable("allGender") + disable("allSex") } else { - enable("allGender") + enable("allSex") } }) @@ -307,9 +307,9 @@ server <- function(input, output, session) { inType <- subset( inType, - school_type %in% input$alevelInstitute & + establishment_type %in% input$alevelInstitute & - characteristic_gender == input$allGender + characteristic_sex == input$allSex ) @@ -320,12 +320,12 @@ server <- function(input, output, session) { observeEvent(input$resetApsAll, { updateSelectizeInput(session, "alevelInstitute", selected = c("All FE sector colleges", "All state-funded schools")) - updateSelectizeInput(session, "allGender", selected = "All students") + updateSelectizeInput(session, "allSex", selected = "All students") }) output$plotAlevelAps <- renderPlot({ createApsTimeSeries(reactiveType(), - allGender = input$allGender, + allSex = input$allSex, instType = input$alevelInstitute ) }) @@ -338,7 +338,7 @@ server <- function(input, output, session) { inType <- dfAlevelAps inType <- subset( inType, - school_type %in% input$alevelInstitute + establishment_type %in% input$alevelInstitute ) inType }) @@ -347,8 +347,8 @@ server <- function(input, output, session) { output$plotFemaleAlAPS <- renderPlot({ createApsFmTimeSeries( reactiveFmAps() %>% - filter(characteristic_gender == "Female" & year > 2015), - fmGender = "Female", + filter(characteristic_sex == "Female" & year > 2015), + fmSex = "Female", instType = input$alevelInstitute ) }) @@ -357,8 +357,8 @@ server <- function(input, output, session) { output$plotMaleAlAPS <- renderPlot({ createApsFmTimeSeries( reactiveFmAps() %>% - filter(characteristic_gender == "Male" & year > 2015), - fmGender = "Male", + filter(characteristic_sex == "Male" & year > 2015), + fmSex = "Male", instType = input$alevelInstitute ) }) @@ -366,37 +366,37 @@ server <- function(input, output, session) { - # Reactive for difference between female and male gender gap APS A level + # Reactive for difference between female and male sex gap APS A level # This is based on female male average result reactiveGgap <- reactive({ gGap <- fmDiff gGap <- subset( gGap, - school_type %in% input$alevelInstitute + establishment_type %in% input$alevelInstitute ) gGap }) output$plotGgap <- renderPlotly({ - createGenderGap(reactiveGgap(), + createSexGap(reactiveGgap(), instType = input$alevelInstitute ) }) selectedGgapData <- reactive({ gGap <- dfAlevelAps %>% - filter(characteristic_gender != "All students" & year >= 2016) - gGap <- subset(gGap, school_type %in% input$alevelInstitute) %>% + filter(characteristic_sex != "All students" & year >= 2016) + gGap <- subset(gGap, establishment_type %in% input$alevelInstitute) %>% select( Year = year, `Academic year` = time_period, - `Institution type` = school_type, - `Characteristic gender` = characteristic_gender, + `Institution type` = establishment_type, + `Characteristic sex` = characteristic_sex, `Number of students` = number_of_students, - `APS per entry` = aps_2016_2023, - `APS per entry grade` = aps_grade_2016_2023, + `APS per entry` = aps_2016_2024, + `APS per entry grade` = aps_grade_2016_2024, Version = version ) }) @@ -431,19 +431,19 @@ server <- function(input, output, session) { output$textHeadline <- renderText({ val <- paste(input$headlineAps, collapse = ",") - # val1<-paste(input$allGender, collapse=", ") + # val1<-paste(input$allSex, collapse=", ") - paste("The boxes display the latest revised average grades in 2022/23 for A level, applied general and tech level. In 2018, there was a large drop in the number of applied general - and tech level students. This was due to the change in the list of tech level and applied general qualifications eligible for reporting in the performance tables. + paste("The box display the latest revised average grades in 2023/24 for A level. The headline attainment does not include vocational and technical qualifications for 2024 provisional data due to a data collection issue. This will be resolved in the revised publication. + In 2018, there was a large drop in the number of applied general and tech level students. This was due to the change in the list of tech level and applied general qualifications eligible for reporting in the performance tables. Point scores for 2020 and 2021 are based on Centre assessment grade and Teacher assessed grade respectively. - The chart shows the APS from 2015/16 to 2022/23 for ", val, " in England. To view results, click on the drop-down box and select one institution type. + The chart shows the APS from 2015/16 to 2023/24 for ", val, " in England. To view results, click on the drop-down box and select one institution type. ") }) output$textApsAll <- renderText({ val <- glue::glue_collapse(input$alevelInstitute, ", ", last = " and ") - val1 <- paste(input$allGender, collapse = ", ") + val1 <- paste(input$allSex, collapse = ", ") HTML(paste("A level average point score (APS) per entry was first published in 2012/13 with a scale of 0-300. The points changed to 0-60 scale in 2015/16, but average grade remains consistent. APS is presented across 2 charts, scales truncated so a change of one grade appears the same for both the old and current points scale (i.e. you can read left to right across the two charts).", br(), " @@ -455,7 +455,7 @@ server <- function(input, output, session) { output$textGgap <- renderText({ val <- glue::glue_collapse(input$alevelInstitute, ", ", last = " and ") - paste("The line chart shows the female - male average points difference (gender gap) from 2015/16 to 2022/23 for ", val, " in England from 2015/16 to 2022/23. + paste("The line chart shows the female - male average points difference (sex gap) from 2015/16 to 2023/24 for ", val, " in England from 2015/16 to 2023/24. Up to four institution types can be selected from the drop-down menu. Care should be taken when comparing across institution types due to significant differences in cohort sizes.") }) @@ -463,9 +463,9 @@ server <- function(input, output, session) { output$textApsFm <- renderText({ val <- glue::glue_collapse(input$alevelInstitute, ", ", last = " and ") - val1 <- paste(input$allGender, collapse = ", ") + val1 <- paste(input$allSex, collapse = ", ") - paste("The line charts display the average points and grades achieved by female and male students for ", val, " in England from 2015/16 to 2022/23. + paste("The line charts display the average points and grades achieved by female and male students for ", val, " in England from 2015/16 to 2023/24. Up to four institution types can be selected from the drop-down menu. Care should be taken when comparing across institution types due to significant differences in cohort sizes. For breakdown of institution types, see flow diagram on left panel.") }) @@ -485,7 +485,7 @@ server <- function(input, output, session) { subjName <- subset( subjName, subject_name %in% input$subCompareAll & - characteristic_gender == input$subByAll & + characteristic_value == input$subByAll & # grade == input$resByAll & between(year, as.numeric(input$year_start), as.numeric(input$year_end)) ) @@ -534,11 +534,11 @@ server <- function(input, output, session) { }) - ## Reactive and output for A level subject by gender ########### + ## Reactive and output for A level subject by sex ########### reactiveSubjectFm <- reactive({ - subjNameFm <- subjectByGender # dfMs + subjNameFm <- subjectBySex # dfMs subjNameFm <- subset( subjNameFm, @@ -644,12 +644,12 @@ server <- function(input, output, session) { subjName <- subjectByAll %>% select( year, time_period, subject_name, - characteristic_gender, entry_count, version + characteristic_value, entry_count, version ) subjName <- subset( subjName, subject_name %in% input$subCompareAll & - characteristic_gender == input$subByAll & + characteristic_value == input$subByAll & between(year, as.numeric(input$year_start), as.numeric(input$year_end)) ) @@ -672,13 +672,13 @@ server <- function(input, output, session) { subjName <- subjectByAll %>% select( year, time_period, subject_name, - characteristic_gender, entry_count, `A*-A`, `A*-B`, + characteristic_value, entry_count, `A*-A`, `A*-B`, `A*-C`, `A*-D`, `A*-E`, version ) subjName <- subset( subjName, subject_name %in% input$subCompareAll & - characteristic_gender == input$subByAll & + characteristic_value == input$subByAll & between(year, as.numeric(input$year_start), as.numeric(input$year_end)) ) @@ -727,12 +727,12 @@ server <- function(input, output, session) { - # Download selected subject entries by gender + # Download selected subject entries by value selectedSubFm <- reactive({ - subjName <- subjectByGender %>% + subjName <- subjectBySex %>% select( year, time_period, subject_name, - characteristic_gender, entry_count, version + characteristic_value, entry_count, version ) subjName <- subset( subjName, @@ -745,7 +745,7 @@ server <- function(input, output, session) { }) output$downloadSubFm <- downloadHandler( - filename = "alevel_subject_gender_data.csv", + filename = "alevel_subject_sex_data.csv", content = function(file) { data <- selectedSubFm() write.csv(data, file, row.names = FALSE) @@ -753,13 +753,13 @@ server <- function(input, output, session) { ) - # Download selected subject entry and all cumulative result for gender + # Download selected subject entry and all cumulative result for sex selectedResFm <- reactive({ - subjName <- subjectByGender %>% + subjName <- subjectBySex %>% select( year, time_period, subject_name, - characteristic_gender, entry_count, `A*-A`, `A*-B`, + characteristic_value, entry_count, `A*-A`, `A*-B`, `A*-C`, `A*-D`, `A*-E`, version ) @@ -792,12 +792,12 @@ server <- function(input, output, session) { select( Year = year, `Academic year` = time_period, - # `Institution group` = school_type_group, - `Institution type` = school_type, - `Characteristic gender` = characteristic_gender, + # `Institution group` = establishment_type_group, + `Institution type` = establishment_type, + `Characteristic sex` = characteristic_sex, `Number of students` = number_of_students, - `APS per entry` = aps_2016_2023, - `APS per entry grade` = aps_grade_2016_2023, + `APS per entry` = aps_2016_2024, + `APS per entry grade` = aps_grade_2016_2024, `APS per entry 2013-2015` = aps_2013_2015, `APS per entry grade 2013-2015` = aps_grade_2013_2015, Version = version @@ -933,12 +933,12 @@ server <- function(input, output, session) { - # Download selected subject entries by gender + # Download selected subject entries by sex selectedSubMs <- reactive({ subjName <- dfMs %>% select( year, time_period, subject, - characteristic_gender, percent_entered, number_of_students, version + characteristic_value, percent_entered, number_of_students, version ) subjName <- subset( subjName, @@ -962,7 +962,7 @@ server <- function(input, output, session) { select( Year = year, `Time period` = time_period, - `Characteristic gender` = characteristic_gender, + `Characteristic value` = characteristic_value, Subject = subject, `Proportion of students` = percent_entered, `Number of students` = number_of_students,