diff --git a/server.R b/server.R index 4b1561e..5c22d97 100644 --- a/server.R +++ b/server.R @@ -1295,13 +1295,13 @@ server <- function(input, output, session) { if (is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) { filtered_data <- cla_rates %>% filter(geo_breakdown %in% input$geographic_breakdown_o1) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # national only } else if (!is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) { filtered_data <- cla_rates %>% filter((geographic_level %in% input$select_geography_o1 & geo_breakdown %in% input$geographic_breakdown_o1) | geographic_level == "National") %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # regional only } else if (is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) { @@ -1310,7 +1310,7 @@ server <- function(input, output, session) { filtered_data <- cla_rates %>% filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name))) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # both selected } else if (!is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) { @@ -1319,14 +1319,14 @@ server <- function(input, output, session) { filtered_data <- cla_rates %>% filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name) | geographic_level == "National")) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) } datatable( filtered_data %>% filter(population_count == "Children starting to be looked after each year") %>% - select(time_period, geo_breakdown, rate_per_10000), - colnames = c("Time period", "Geographical breakdown", "Rate of children starting in care, per 10,000"), + select(time_period, geo_breakdown, number, rate_per_10000), + colnames = c("Time period", "Geographical breakdown", "Number of children starting in care", "Rate of children starting in care, per 10,000"), options = list( scrollx = FALSE, paging = TRUE @@ -1356,10 +1356,10 @@ server <- function(input, output, session) { datatable( cla_rates %>% filter(geographic_level == "Regional", time_period == max(cla_rates$time_period), population_count == "Children starting to be looked after each year") %>% select( time_period, geo_breakdown, - rate_per_10000 + number, rate_per_10000 ) %>% arrange(desc(rate_per_10000)), - colnames = c("Time period", "Geographical breakdown", "Rate of children starting in care, per 10,000"), + colnames = c("Time period", "Geographical breakdown", "Number of children starting in care", "Rate of children starting in care, per 10,000"), options = list( scrollx = FALSE, paging = TRUE @@ -1401,21 +1401,21 @@ server <- function(input, output, session) { data <- cla_rates %>% filter(geo_breakdown %in% location, time_period == max(time_period), population_count == "Children starting to be looked after each year") %>% - select(time_period, geo_breakdown, rate_per_10000) %>% + select(time_period, geo_breakdown, number, rate_per_10000) %>% arrange(desc(rate_per_10000)) } else if (input$select_geography_o1 %in% c("Local authority", "National")) { data <- cla_rates %>% filter(geographic_level == "Local authority", time_period == max(cla_rates$time_period), population_count == "Children starting to be looked after each year") %>% select( time_period, geo_breakdown, - rate_per_10000 + number, rate_per_10000 ) %>% arrange(desc(rate_per_10000)) } datatable( data, - colnames = c("Time period", "Geographical breakdown", "Rate of children starting in care, per 10,000"), + colnames = c("Time period", "Geographical breakdown", "Number of children starting in care", "Rate of children starting in care, per 10,000"), options = list( scrollx = FALSE, paging = TRUE @@ -1824,6 +1824,7 @@ server <- function(input, output, session) { ) }) + # UASC chart output$plot_uasc <- plotly::renderPlotly({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1836,6 +1837,7 @@ server <- function(input, output, session) { ) }) + # UASC table output$table_uasc <- renderDataTable({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1848,9 +1850,9 @@ server <- function(input, output, session) { characteristic %in% c("Unaccompanied asylum-seeking children", "Non-unaccompanied asylum-seeking children"), population_count == "Children starting to be looked after each year" ) %>% - select(time_period, geo_breakdown, placement_per_10000, characteristic) %>% + select(time_period, geo_breakdown, characteristic, placements_number, placement_per_10000) %>% arrange(desc(time_period)), - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children", "UASC status"), + colnames = c("Time period", "Geographical breakdown", "UASC status", "Number of children starting in care", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE, @@ -1859,6 +1861,7 @@ server <- function(input, output, session) { ) }) + # UASC chart by region output$plot_uasc_reg <- plotly::renderPlotly({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1871,6 +1874,7 @@ server <- function(input, output, session) { ) }) + # UASC table by region output$table_uasc_reg <- renderDataTable({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1882,8 +1886,8 @@ server <- function(input, output, session) { population_count == "Children starting to be looked after each year", time_period == max(time_period) ) %>% - select(time_period, geo_breakdown, placement_per_10000, characteristic), - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children", "UASC status"), + select(time_period, geo_breakdown, characteristic, placements_number, placement_per_10000), + colnames = c("Time period", "Geographical breakdown", "UASC status", "Number of children starting in care", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE @@ -1891,6 +1895,7 @@ server <- function(input, output, session) { ) }) + # UASC plot by LA output$plot_uasc_la <- plotly::renderPlotly({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1903,6 +1908,7 @@ server <- function(input, output, session) { ) }) + # UASC table by LA output$table_uasc_la <- renderDataTable({ shiny::validate( need(input$select_geography_o1 != "", "Select a geography level."), @@ -1926,7 +1932,7 @@ server <- function(input, output, session) { geo_breakdown %in% location, time_period == max(combined_cla_data$time_period), characteristic %in% c("Unaccompanied asylum-seeking children", "Non-unaccompanied asylum-seeking children"), population_count == "Children starting to be looked after each year", ) %>% - select(time_period, geo_breakdown, placement_per_10000, characteristic) %>% + select(time_period, geo_breakdown, characteristic, placements_number, placement_per_10000) %>% arrange(desc(placement_per_10000)) } else if (input$select_geography_o1 %in% c("Local authority", "National")) { data <- combined_cla_data %>% @@ -1934,13 +1940,13 @@ server <- function(input, output, session) { geographic_level == "Local authority", time_period == max(combined_cla_data$time_period), characteristic %in% c("Unaccompanied asylum-seeking children", "Non-unaccompanied asylum-seeking children"), population_count == "Children starting to be looked after each year", ) %>% - select(time_period, geo_breakdown, placement_per_10000, characteristic) %>% + select(time_period, geo_breakdown, characteristic, placements_number, placement_per_10000) %>% arrange(desc(placement_per_10000)) } datatable( data, - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children", "UASC status"), + colnames = c("Time period", "Geographical breakdown", "UASC status", "Number of children starting in care", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE @@ -2008,13 +2014,13 @@ server <- function(input, output, session) { if (is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) { filtered_data <- cla_rates %>% filter(geo_breakdown %in% input$geographic_breakdown_o1) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # national only } else if (!is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) { filtered_data <- cla_rates %>% filter((geographic_level %in% input$select_geography_o1 & geo_breakdown %in% input$geographic_breakdown_o1) | geographic_level == "National") %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # regional only } else if (is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) { @@ -2023,7 +2029,7 @@ server <- function(input, output, session) { filtered_data <- cla_rates %>% filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name))) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) # both selected } else if (!is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) { @@ -2032,14 +2038,14 @@ server <- function(input, output, session) { filtered_data <- cla_rates %>% filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name) | geographic_level == "National")) %>% - select(time_period, geo_breakdown, rate_per_10000, population_count) + select(time_period, geo_breakdown, number, rate_per_10000, population_count) } datatable( filtered_data %>% filter(population_count == "Children looked after at 31 March each year") %>% - select(time_period, geo_breakdown, rate_per_10000), - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children"), + select(time_period, geo_breakdown, number, rate_per_10000), + colnames = c("Time period", "Geographical breakdown", "Number of children looked after on 31 March", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE @@ -2069,10 +2075,10 @@ server <- function(input, output, session) { datatable( cla_rates %>% filter(geographic_level == "Regional", time_period == max(cla_rates$time_period), population_count == "Children looked after at 31 March each year") %>% select( time_period, geo_breakdown, - rate_per_10000 + number, rate_per_10000 ) %>% arrange(desc(rate_per_10000)), - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children"), + colnames = c("Time period", "Geographical breakdown", "Number of children looked after on 31 March", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE @@ -2114,21 +2120,21 @@ server <- function(input, output, session) { data <- cla_rates %>% filter(geo_breakdown %in% location, time_period == max(time_period), population_count == "Children looked after at 31 March each year") %>% - select(time_period, geo_breakdown, rate_per_10000) %>% + select(time_period, geo_breakdown, number, rate_per_10000) %>% arrange(desc(rate_per_10000)) } else if (input$select_geography_o1 %in% c("Local authority", "National")) { data <- cla_rates %>% filter(geographic_level == "Local authority", time_period == max(cla_rates$time_period), population_count == "Children looked after at 31 March each year") %>% select( time_period, geo_breakdown, - rate_per_10000 + number, rate_per_10000 ) %>% arrange(desc(rate_per_10000)) } datatable( data, - colnames = c("Time period", "Geographical breakdown", "Rate per 10,000 children"), + colnames = c("Time period", "Geographical breakdown", "Number of children looked after on 31 March", "Rate per 10,000 children"), options = list( scrollx = FALSE, paging = TRUE