Skip to content

Commit

Permalink
Merge branch 'yauemily:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
nataliepaterson authored Mar 11, 2024
2 parents a05714e + 09a70f5 commit 8426039
Show file tree
Hide file tree
Showing 6 changed files with 726 additions and 14 deletions.
215 changes: 205 additions & 10 deletions R/outcome2_page.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,86 @@ outcome2_tab <- function(){
div(
class = "input_box",
style = "min-height:100%; height = 100%; overflow-y: visible",
gov_row(
column(
width = 6,
h2("Inputs go here")
layout_columns(
selectizeInput(
inputId = "select_geography_o2",
label = "Select a geographical level:",
choices = unique(workforce_data %>% pull('geographic_level')),
selected = NULL,
multiple = FALSE,
options = NULL
),
column(
width = 6,
h2("Inputs go here")
)
conditionalPanel(condition = "input.select_geography_o2 != 'National'",
selectizeInput(
inputId = "geographic_breakdown_o2",
label = "Select a breakdown: ",
choices = NULL,
selected = NULL,
multiple = FALSE,
options = NULL
)),
col_widths = c(4,8)
),
layout_columns(
conditionalPanel(condition = "input.select_geography_o2 != 'National'",
column(
width = 3,
checkbox_Input(
inputId = "national_comparison_checkbox_o2",
cb_labels = "Compare with National",
checkboxIds = "Yes_national",
label = "",
hint_label = NULL,
small = TRUE
)
)),
conditionalPanel(
condition = "(input.select_geography_o2 == 'Local authority')",
column(
width = 3,
checkbox_Input(
inputId = "region_comparison_checkbox_o2",
cb_labels = "Compare with Region",
checkboxIds = "Yes_region",
label = "",
hint_label = NULL,
small = TRUE
)
)), col_widths = c(4,8)
)
)
),
# gov_row(
# div(
# class = "input_box",
# style = "min-height:100%; height = 100%; overflow-y: visible",
# gov_row(
# column(
# width = 6,
# h2("Inputs go here")
# ),
# column(
# width = 6,
# h2("Inputs go here")
# )
# )
# )
# ),
br(),
gov_row(
br(),
h2("Confirmation Sentence"),
p(htmlOutput("outcome2_choice_text1"),htmlOutput("outcome2_choice_text2")),
conditionalPanel(
condition = "(input.geographic_breakdown_o2 == 'Northamptonshire')",
p("To view 2021 and onwards data select ", strong("North Northamptonshire"),"or", strong("West Northamptonshire"),". Northamptonshire local authority was replaced with two new unitary authorities, North Northamptonshire and West Northamptonshire, in April 2021.") ),
conditionalPanel(
condition = "(input.geographic_breakdown_o2 == 'Poole')",
p("To view 2020 and onwards data select ", strong("Bournemouth, Christchurch and Poole"),". Bournemouth, Christchurch and Poole local authority was formed in April 2019.") ),
conditionalPanel(
condition = "(input.geographic_breakdown_o2 == 'Bournemouth')",
p("To view 2020 and onwards data select ", strong("Bournemouth, Christchurch and Poole"),". Bournemouth, Christchurch and Poole local authority was formed in April 2019.") ),
),
gov_row(
br(),
div(
tabsetPanel(
Expand All @@ -37,7 +101,138 @@ outcome2_tab <- function(){
tabPanel(
"Families engaging and receiving support from their family network",
fluidRow(
p("testing")
br()
),
fluidRow(
column(
width = 6,
value_box(
title = "Percentage of children who cease being looked after due to moving into Special Guardianship Order (SGO)",
value = htmlOutput("SGO_headline_txt")
)
),
column(
width = 6,
value_box(
title = "Percentage of children who cease being looked after due to moving into Residence order or Child Arrangement Order (CAO)",
value = htmlOutput("CAO_headline_txt")
)
),
br(),
p("Unlocking family networks and kinship carers can be a key source of support where families are experiencing challenges.
Moving children from care arrangements to a SGO or CAO shows that kinship care is being prioritised where children cannot safely live with their parents.")
),

accordion(
accordion_panel(
"Percentage of children who cease being looked after due to moving into Special Guardianship Order (SGO)",
gov_row(
h2("Special Guardianship Order (SGO)"),
#p("Unlocking family networks and kinship carers can be a key source of support where families are experiencing challenges.
#Moving children from care arrangements to a SGO or CAO shows that kinship care is being prioritised where children cannot safely live with their parents."),
br(),
plotlyOutput("SGO_time_series"),
br(),
details(
inputId = "tbl_sgo_ceased_cla",
label = "View chart as table",
help_text = (
dataTableOutput("table_sgo_ceased")
)
),
details(
inputId = "sgo_info",
label = "Additional information:",
help_text = (
p("For more information on the data and definitions, please refer to the", a(href = "https://explore-education-statistics.service.gov.uk/find-statistics/children-looked-after-in-england-including-adoptions/data-guidance", "Children looked after in England including adoptions guidance."),
tags$br(),
"For more information on the methodology, please refer to the", a(href = "https://explore-education-statistics.service.gov.uk/methodology/children-looked-after-in-england-including-adoptions", "Children looked after in England including adoptions methodology.")))
)
),
gov_row(
h2("Special Guardianship Order (SGO) by region"),
p("This is a static chart and will not react to geographical level and breakdown selected in the filters at the top.
The graph represents data from 2023."),
br(),
plotlyOutput("plot_sgo_ceased_reg"),
br(),
details(
inputId = "tbl_sgo_ceased_cla_reg",
label = "View chart as table",
help_text = (
dataTableOutput("table_sgo_ceased_reg")
)
)
),
gov_row(
h2("Special Guardianship Order (SGO) by local authority"),
p("This chart is reactive to the Local Authority and Regional filters at the top and will not react to the National filter. The chart will display all Local Authorities overall or every Local Authority in the selected Region.
The graph represents data from 2023."),
br(),
plotlyOutput("plot_SGO_la"),
br(),
details(
inputId = "tbl_sgo_ceased_la",
label = "View chart as table",
help_text = (
dataTableOutput("table_sgo_la")
)
)
)
),
accordion_panel(
"Percentage of children who cease being looked after due to moving into Care Arrangement Order (CAO)",
gov_row(
h2("Residence order or Child Arrangement Order (CAO)"),
p("Unlocking family networks and kinship carers can be a key source of support where families are experiencing challenges.
Moving children from care arrangements to a SGO or CAO shows that kinship care is being prioritised where children cannot safely live with their parents."),
br(),
plotlyOutput("CAO_time_series"),
br(),
details(
inputId = "tbl_cao_ceased_cla",
label = "View chart as table",
help_text = (
dataTableOutput("table_cao_ceased")
)
),
),
gov_row(
h2("Residence order or Child Arrangement Order (CAO) by region"),
p("This is a static chart and will not react to geographical level and breakdown selected in the filters at the top.
The graph represents data from 2023."),
br(),
plotlyOutput("plot_cao_ceased_reg"),
br(),
details(
inputId = "table_cao_ceased_reg",
label = "View chart as table",
help_text = (
dataTableOutput("table_cao_ceased_reg")
)
),
),
gov_row(
h2("Residence order or Child Arrangement Order (CAO) by local authority"),
p("This chart is reactive to the Local Authority and Regional filters at the top and will not react to the National filter. The chart will display all Local Authorities overall or every Local Authority in the selected Region.
The graph represents data from 2023."),
br(),
plotlyOutput("plot_cao_la"),
br(),
details(
inputId = "table_cao_la",
label = "View chart as table",
help_text = (
dataTableOutput("table_cao_la")
)
),
)
)
, open = FALSE
)
)
)
Expand Down
103 changes: 103 additions & 0 deletions R/read_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -538,3 +538,106 @@ read_cin_referral_data <- function(file = "data/c1_children_in_need_referrals_an

return(cin_referral_data)
}
# Outcome 2 ----
# read_outcome2 <- function(file = "data/la_children_who_ceased_during_the_year.csv"){
# ceased_cla_data <- read.csv(file)
# ceased_cla_data <- ceased_cla_data %>% mutate(geo_breakdown = case_when(
# geographic_level == "National" ~ "National",#NA_character_,
# geographic_level == "Regional" ~ region_name,
# geographic_level == "Local authority" ~ la_name
# )) %>%
# mutate(number = case_when(
# number == "z" ~ NA,
# number == "x" ~ NA,
# number == "c" ~ NA,
# TRUE ~ as.numeric(number)
# )) %>%
# select("time_period", "geographic_level","geo_breakdown", "cla_group","characteristic", "number", "percentage")
# }
# read_outcome2 <- function(file = "data/la_children_who_ceased_during_the_year.csv"){
# ceased_cla_data <- read.csv(file)
# ceased_cla_data <- ceased_cla_data %>% mutate(geo_breakdown = case_when(
# geographic_level == "National" ~ "National",#NA_character_,
# geographic_level == "Regional" ~ region_name,
# geographic_level == "Local authority" ~ la_name
# )) %>%
# mutate(number = case_when(
# number == "z" ~ NA,
# number == "x" ~ NA,
# number == "c" ~ NA,
# TRUE ~ as.numeric(number)
# )) %>%
# select("time_period", "geographic_level","geo_breakdown", "cla_group","characteristic", "number", "percentage")
#
# totals <- ceased_cla_data %>% filter(characteristic == "Total" & cla_group == "Reason episode ceased") %>%
# rename("Total" = "number") %>%
# select(time_period, geographic_level, geo_breakdown, cla_group, Total)
#
#
# test<- ceased_cla_data %>% filter(cla_group == "Reason episode ceased" & characteristic != "Total")
#
# joined <- left_join(test, totals, by = c("time_period", "geographic_level","geo_breakdown", "cla_group"))
# joined$perc <- round((joined$number/joined$Total)*100, digits = 1)
# joined <- joined %>% mutate(perc = case_when(
# percentage == "z" ~ "z",
# percentage == "c" ~ "c",
# percentage == "k" ~ "k",
# percentage == "x" ~ "x",
# TRUE ~ as.character(perc))) %>% mutate(`Percentage ceased %` = case_when(
# percentage == "z" ~ NA,
# percentage == "c" ~ NA,
# percentage == "k" ~ NA,
# percentage == "x" ~ NA,
# TRUE ~ as.numeric(perc)
# ))
#
# return(joined)
# }

read_outcome2 <- function(file = "data/la_children_who_ceased_during_the_year.csv"){
ceased_cla_data <- read.csv(file)
old_dorset <- ceased_cla_data %>% filter(time_period <= 2019, new_la_code == "E10000009")
new_dorset <- ceased_cla_data %>% filter(time_period > 2019, new_la_code == "E06000059")
data_without_dorset <- ceased_cla_data %>% filter(la_name != "Dorset")

dorset_data <- bind_rows(new_dorset, old_dorset)
final_filtered_data <- bind_rows(data_without_dorset, dorset_data)

ceased_cla_data <- final_filtered_data %>% mutate(geo_breakdown = case_when(
geographic_level == "National" ~ "National",#NA_character_,
geographic_level == "Regional" ~ region_name,
geographic_level == "Local authority" ~ la_name
)) %>%
mutate(number = case_when(
number == "z" ~ NA,
number == "x" ~ NA,
number == "c" ~ NA,
TRUE ~ as.numeric(number)
)) %>%
filter("new_la_code" != "E10000009") %>%
select("time_period", "geographic_level","geo_breakdown", "cla_group","characteristic", "number", "percentage")

totals <- ceased_cla_data %>% filter(characteristic == "Total" & cla_group == "Reason episode ceased") %>%
rename("Total" = "number") %>%
select(time_period, geographic_level, geo_breakdown, cla_group, Total)


test<- ceased_cla_data %>% filter(cla_group == "Reason episode ceased" & characteristic != "Total")

joined <- left_join(test, totals, by = c("time_period", "geographic_level","geo_breakdown", "cla_group"))
joined$perc <- round((joined$number/joined$Total)*100, digits = 1)
joined <- joined %>% mutate(perc = case_when(
percentage == "z" ~ "z",
percentage == "c" ~ "c",
percentage == "k" ~ "k",
percentage == "x" ~ "x",
TRUE ~ as.character(perc))) %>% mutate(`Ceased (%)` = case_when(
percentage == "z" ~ NA,
percentage == "c" ~ NA,
percentage == "k" ~ NA,
percentage == "x" ~ NA,
TRUE ~ as.numeric(perc)
))

return(joined)
}
8 changes: 6 additions & 2 deletions global.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,13 @@ combined_cla_data <- merge_cla_dataframes()
cin_rates <- read_cin_rate_data()
cin_referrals <- read_cin_referral_data()


#Read in outcome 2 data
ceased_cla_data <- read_outcome2()

#Dropdowns
choice_breakdown_level <- workforce_data %>% select(geographic_level) %>% filter(geographic_level != "National")%>% distinct()
choices_LA <- workforce_data %>% filter(geographic_level == "Local authority") %>% select()
#choice_breakdown_level <- workforce_data %>% select(geographic_level) %>% filter(geographic_level != "National")%>% distinct()
#choices_LA <- workforce_data %>% filter(geographic_level == "Local authority") %>% select()

#choices_geographic_level <- dropdown_choices %>% select(geographic_level) %>% distinct()

Expand Down
Loading

0 comments on commit 8426039

Please sign in to comment.