Skip to content

Commit

Permalink
Added CIN number into tables with symbols in
Browse files Browse the repository at this point in the history
  • Loading branch information
PATERSON authored and PATERSON committed Mar 25, 2024
1 parent 6c59ff3 commit fe00f00
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 21 deletions.
11 changes: 4 additions & 7 deletions R/read_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -521,24 +521,21 @@ read_cin_rate_data <- function(file = "data/b1_children_in_need_2013_to_2023.csv
geographic_level == "Regional" ~ region_name,
geographic_level == "Local authority" ~ la_name
)) %>%
mutate(At31_episodes = case_when(
mutate(CIN_number = case_when(
At31_episodes == "Z" ~ NA,
At31_episodes == "x" ~ NA,
At31_episodes == "c" ~ NA,
TRUE ~ as.numeric(At31_episodes)
)) %>%
mutate(At31_episodes_rate = case_when(
mutate(CIN_rate = case_when(
At31_episodes_rate == "Z" ~ NA,
At31_episodes_rate == "x" ~ NA,
At31_episodes_rate == "c" ~ NA,
TRUE ~ as.numeric(At31_episodes_rate)
)) %>%
select(geographic_level, geo_breakdown, time_period, region_code, region_name, new_la_code, la_name, At31_episodes, At31_episodes_rate) %>%
select(geographic_level, geo_breakdown, time_period, region_code, region_name, new_la_code, la_name, CIN_number, At31_episodes, CIN_rate, At31_episodes_rate) %>%
distinct() %>%
rename(CIN_rate = At31_episodes_rate, CIN_number = At31_episodes)


return(cin_rate_data)
return(cin_rate_data)
}

# CIN referrals data
Expand Down
28 changes: 14 additions & 14 deletions server.R
Original file line number Diff line number Diff line change
Expand Up @@ -1460,10 +1460,10 @@ server <- function(input, output, session) {
datatable(
cin_rates %>% filter(geographic_level == "Regional", time_period == max(cin_rates$time_period)) %>% select(
time_period, geo_breakdown,
CIN_rate
At31_episodes, At31_episodes_rate
) %>%
arrange(desc(CIN_rate)),
colnames = c("Time period", "Geographical breakdown", "CIN rate per 10,000"),
arrange(desc(At31_episodes_rate)),
colnames = c("Time period", "Geographical breakdown", "CIN number at 31 March", "CIN rate per 10,000"),
options = list(
scrollx = FALSE,
paging = TRUE
Expand Down Expand Up @@ -1494,21 +1494,21 @@ server <- function(input, output, session) {

data <- cin_rates %>%
filter(geo_breakdown %in% location, time_period == max(time_period)) %>%
select(time_period, geo_breakdown, CIN_rate) %>%
arrange(desc(CIN_rate))
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate) %>%
arrange(desc(At31_episodes_rate))
} else if (input$select_geography_o1 %in% c("Local authority", "National")) {
data <- cin_rates %>%
filter(geographic_level == "Local authority", time_period == max(cin_rates$time_period)) %>%
select(
time_period, geo_breakdown,
CIN_rate
At31_episodes, At31_episodes_rate
) %>%
arrange(desc(CIN_rate))
arrange(desc(At31_episodes_rate))
}

datatable(
data,
colnames = c("Time period", "Geographical breakdown", "CIN rates per 10,000"),
colnames = c("Time period", "Geographical breakdown", "CIN number at 31 March", "CIN rates per 10,000"),
options = list(
scrollx = FALSE,
paging = TRUE
Expand Down Expand Up @@ -1599,13 +1599,13 @@ server <- function(input, output, session) {
if (is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) {
filtered_data <- cin_rates %>%
filter(geo_breakdown %in% input$geographic_breakdown_o1) %>%
select(time_period, geo_breakdown, CIN_number, CIN_rate)
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate)

# national only
} else if (!is.null(input$national_comparison_checkbox_o1) && is.null(input$region_comparison_checkbox_o1)) {
filtered_data <- cin_rates %>%
filter((geographic_level %in% input$select_geography_o1 & geo_breakdown %in% input$geographic_breakdown_o1) | geographic_level == "National") %>%
select(time_period, geo_breakdown, CIN_number, CIN_rate)
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate)

# regional only
} else if (is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) {
Expand All @@ -1614,7 +1614,7 @@ server <- function(input, output, session) {

filtered_data <- cin_rates %>%
filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name))) %>%
select(time_period, geo_breakdown, CIN_number, CIN_rate)
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate)

# both selected
} else if (!is.null(input$national_comparison_checkbox_o1) && !is.null(input$region_comparison_checkbox_o1)) {
Expand All @@ -1623,13 +1623,13 @@ server <- function(input, output, session) {

filtered_data <- cin_rates %>%
filter((geo_breakdown %in% c(input$geographic_breakdown_o1, location$region_name) | geographic_level == "National")) %>%
select(time_period, geo_breakdown, CIN_number, CIN_rate)
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate)
}

datatable(
filtered_data %>%
select(time_period, geo_breakdown, CIN_number, CIN_rate),
colnames = c("Time period", "Geographical breakdown", "CIN at 31 March", "CIN rate per 10,000"),
select(time_period, geo_breakdown, At31_episodes, At31_episodes_rate),
colnames = c("Time period", "Geographical breakdown", "CIN number at 31 March", "CIN rate per 10,000"),
options = list(
scrollx = FALSE,
paging = TRUE
Expand Down

0 comments on commit fe00f00

Please sign in to comment.