generated from dfe-analytical-services/shiny-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Feat: Defined tooltip fn for Trend on LA level page, along with some css styling * Feat: Applying Trend tooltip to all module pages * Feat: Improving thr quartile band calculation so is rounded and states the limits of each QB * Feat: Adding new quartile banding styling to LA mod, switch high polarity so QBs in order * Tests: Updated build LA stats table tests for new fn * Feat: Adding tooltip for rank explaining that 1 is always the best performer * Feat: Added rank tooltip to stat neigh page * Feat: Added state-funded flag to LA dev app, but decision to not include atm * Feat: Adding spinner to the LA tables * Feat: Customising spinners * Feat: Creating gov style spinner and applying to tables and charts in LA mod * Feat: Closable notification banner added to create own to point users to GitHub * Chore: Adding spinner pkg to renv * Data: Updating BDS, also adding a .csv version og BDS long for public download * Fix: Adding .. to list of non numeric values in BDS so no warning, updating bar chart * Feat: Replacing dash with "" for create own missing but due to query, also applied to the download * Feat: Quartile banding now has white text if coloured background and removed some unecessary code fromLA workshop * Chore: Removing uneeded columns from BDS long and updating files accordingly (.csv was very large mb) * Feat: Trialling new rank tooltip content * Fix: Fixing trend arrow colour issue where no change was appearing red * Feat: Adding spinner to page header * Feat: Handling for COVID missing data in charts, currently LA workshop and dev app * Feat: Functionising covid plotting elements * Feat: Adding chart type option for covid plot fn * Feat: Adding covid plotting to bar charts in LA workshop and dev app, adjusting vjust so slightly higher label * Feat: Added new covid plotting fns to LA mod charts * Feat: Added new covid plotting fns to Region mod charts * Feat: Added new covid plotting fns to Stat Neigh mod charts * Feat: Adding COVID fns to create own, formatting fns and custom-theme to adapt * Feat: Covid plotting added to create own bar chart - just label * Feat: Covid plotting added to main scripts * Feat: Showing covid plot on bar in create own for matching covid lengths * Feat: Bar chart in create own now has working covid data plot per chart * Tests: Updating LA charts server test for covid affected indicators and also screenshot for new covid line * Feat: Combined create own bar chart covid plotting fns * Feat: Adding roxygen comments for new COVID plotting fns * Fix: Adding NaN fill to pivot wider in staging so that if two different indicators added in one query it will pick up user created NAs * Feat: Adding gov spinners to the other page mods (bar Create Own) * Feat: Adding spinner to Create Own tables and Charts * Fix: Improving width of the Create Own bar chart so x-axis clearer * Chore: Adding black dash highlight option to all bar charts * Tests: Corrected test for new bar chart hover functionality
- Loading branch information
Showing
38 changed files
with
537,773 additions
and
4,724 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,160 +1,155 @@ | ||
--- | ||
title: "LAIT - Shiny upgrade" | ||
subtitle: "Workings and development code" | ||
format: html | ||
date-modified: "`r Sys.Date()`" | ||
output: | ||
html_document: | ||
toc: true | ||
output-file: lait_workings | ||
embed-resources: true | ||
execute: | ||
echo: false | ||
cache: true | ||
message: false | ||
warning: false | ||
--- | ||
|
||
|
||
```{r src-funs} | ||
source(here::here("R/fn_helper_functions.R")) | ||
source(here::here("R/fn_load_data.R")) | ||
``` | ||
|
||
|
||
```{r pull-latest-bds-data} | ||
# Load raw BDS wide from shared folder | ||
bds_wide_raw_sf <- readxl::read_xlsx( | ||
path = paste0(shared_folder, "/../Information for App Development/BDS - 2024 (JAKE).xlsx"), | ||
sheet = "BDS for new LAIT", | ||
col_names = TRUE, | ||
skip = 1, | ||
# Replace multi-space with single-space | ||
.name_repair = clean_spaces, | ||
col_types = "text" | ||
) | ||
# Save to data folder | ||
write.csv( | ||
bds_wide_raw_sf, | ||
here::here("01_data/01_raw/BDS_Wide.csv"), | ||
row.names = FALSE | ||
) | ||
``` | ||
|
||
|
||
```{r load-bds} | ||
# Load BDS wide | ||
bds_wide_raw <- read.csv( | ||
here::here("01_data/01_raw/BDS_Wide.csv"), | ||
check.names = FALSE | ||
) | ||
# styler: off | ||
# Remove any cols that are all na | ||
bds_wide <- bds_wide_raw |> | ||
{ \(.) dplyr::select(., dplyr::all_of(non_empty_colnames(.))) }() # nolint: brace | ||
# styler: on | ||
``` | ||
|
||
|
||
```{r wide-long} | ||
# Pivot BDS long on geographic cols | ||
bds_long <- bds_wide |> | ||
tidyr::pivot_longer( | ||
cols = `Barking and Dagenham`:`South West`, | ||
names_to = "LA and Regions", | ||
values_to = "Values" | ||
) |> | ||
# Removes these lines with matching entries in year column | ||
dplyr::filter( | ||
Years %notin% c( | ||
"-", | ||
"", | ||
"Trend", | ||
"Change", | ||
"Rank", | ||
"Target", | ||
"Distance", | ||
"Quartile", | ||
"Deviation National", | ||
"% YoY change", | ||
"%3yr change", | ||
"2010 Target", | ||
"Target 2011", | ||
"NA - Distance", | ||
is.na(0) | ||
) | ||
) | ||
``` | ||
|
||
|
||
```{r bds-clean} | ||
# Vector to store columns to delete | ||
columns_to_delete <- c( | ||
"Quartile 1 (A)", | ||
"Quartile 2 (B)", | ||
"Quartile 3 (C )", | ||
"Quartile 4 (D)", | ||
"line", | ||
"Data item" | ||
) | ||
# Delete lines in vector from column, remove '.'s and underscores/number | ||
bds_long_clean <- bds_long |> | ||
dplyr::select(!dplyr::all_of(columns_to_delete)) |> | ||
dplyr::mutate( | ||
"LA and Regions" = stringr::str_replace_all(`LA and Regions`, "\\.", " "), | ||
"LA and Regions" = stringr::str_replace_all(`LA and Regions`, " ", "\\. "), | ||
# Remove final _ and following digits | ||
# NOTE: Also remove whitespace - 'LACStableNum_2016on' | ||
`Short Desc` = trimws(sub("_\\d+$", "", `Short Desc`)) | ||
) | ||
``` | ||
|
||
|
||
```{r bds-la_codes} | ||
# Load LA codes | ||
la_codes <- readxl::read_xlsx( | ||
path = here::here("01_data/02_prod/LA code list.xlsx") | ||
) | ||
# Join to bds and create combined codes var | ||
bds_long_la <- bds_long_clean |> | ||
dplyr::left_join(la_codes, by = c("LA and Regions" = "LA Name")) |> | ||
dplyr::mutate(combined_code = paste(`LA Number`, `Short Desc`, Years, | ||
sep = "_" | ||
)) | ||
``` | ||
|
||
|
||
```{r bds-data_dict} | ||
# Pull list of measures from data dictionary (primary key and filters for | ||
# only public-safe/in-use measures) | ||
# NOTE: Children_away changed to Children_Away to match BDS | ||
data_dict <- readxl::read_xlsx( | ||
path = paste0("01_data/02_prod/LAIT Data Dictionary.xlsx"), | ||
sheet = "Data_prod" | ||
) |> | ||
dplyr::mutate(Measure_short = trimws(Measure_short)) |> | ||
dplyr::filter(!grepl("DISCONTINUE", Table_status)) |> | ||
pull_uniques("Measure_short") | ||
# Filter BDS for only measures in the data dict | ||
bds_long_public <- bds_long_la |> | ||
dplyr::filter(`Short Desc` %in% data_dict) | ||
``` | ||
|
||
|
||
```{r bds-save} | ||
# Write out parquet version | ||
arrow::write_dataset( | ||
bds_long_public, | ||
here::here("01_data/02_prod/"), | ||
format = "parquet", | ||
basename_template = "bds_long_{i}.parquet" | ||
) | ||
``` | ||
--- | ||
title: "LAIT - Shiny upgrade" | ||
subtitle: "Workings and development code" | ||
format: html | ||
date-modified: "`r Sys.Date()`" | ||
output: | ||
html_document: | ||
toc: true | ||
output-file: lait_workings | ||
embed-resources: true | ||
execute: | ||
echo: false | ||
cache: true | ||
message: false | ||
warning: false | ||
--- | ||
|
||
|
||
```{r src-funs} | ||
source(here::here("R/fn_helper_functions.R")) | ||
source(here::here("R/fn_load_data.R")) | ||
``` | ||
|
||
|
||
```{r pull-latest-bds-data} | ||
# Load raw BDS wide from shared folder | ||
bds_wide_raw_sf <- readxl::read_xlsx( | ||
path = paste0(shared_folder, "/../Information for App Development/BDS - 2024 (JAKE).xlsx"), | ||
sheet = "BDS New", | ||
col_names = TRUE, | ||
skip = 1, | ||
# Replace multi-space with single-space | ||
.name_repair = clean_spaces, | ||
col_types = "text" | ||
) | ||
# Save to data folder | ||
write.csv( | ||
bds_wide_raw_sf, | ||
here::here("01_data/01_raw/BDS_Wide.csv"), | ||
row.names = FALSE | ||
) | ||
``` | ||
|
||
|
||
```{r load-bds} | ||
# Load BDS wide | ||
bds_wide_raw <- read.csv( | ||
here::here("01_data/01_raw/BDS_Wide.csv"), | ||
check.names = FALSE | ||
) | ||
# styler: off | ||
# Remove any cols that are all na | ||
bds_wide <- bds_wide_raw |> | ||
{ \(.) dplyr::select(., dplyr::all_of(non_empty_colnames(.))) }() # nolint: brace | ||
# styler: on | ||
``` | ||
|
||
|
||
```{r wide-long} | ||
# Pivot BDS long on geographic cols | ||
bds_long <- bds_wide |> | ||
tidyr::pivot_longer( | ||
cols = `Barking and Dagenham`:`South West`, | ||
names_to = "LA and Regions", | ||
values_to = "Values" | ||
) |> | ||
# Removes these lines with matching entries in year column | ||
dplyr::filter( | ||
Years %notin% c( | ||
"-", | ||
"", | ||
"Trend", | ||
"Change", | ||
"Rank", | ||
"Target", | ||
"Distance", | ||
"Quartile", | ||
"Deviation National", | ||
"% YoY change", | ||
"%3yr change", | ||
"2010 Target", | ||
"Target 2011", | ||
"NA - Distance", | ||
is.na(0) | ||
) | ||
) | ||
``` | ||
|
||
|
||
```{r bds-clean} | ||
# Delete lines in vector from column, remove '.'s and underscores/number | ||
bds_long_clean <- bds_long |> | ||
dplyr::select(-line) |> | ||
dplyr::mutate( | ||
"LA and Regions" = stringr::str_replace_all(`LA and Regions`, "\\.", " "), | ||
"LA and Regions" = stringr::str_replace_all(`LA and Regions`, " ", "\\. "), | ||
# Remove final _ and following digits | ||
# NOTE: Also remove whitespace - 'LACStableNum_2016on' | ||
`Short Desc` = trimws(sub("_\\d+$", "", `Short Desc`)) | ||
) | ||
``` | ||
|
||
|
||
```{r bds-la_codes} | ||
# Load LA codes | ||
la_codes <- readxl::read_xlsx( | ||
path = here::here("01_data/02_prod/LA code list.xlsx") | ||
) | ||
# Join to bds and create combined codes var | ||
bds_long_la <- bds_long_clean |> | ||
dplyr::left_join(la_codes, by = c("LA and Regions" = "LA Name")) |> | ||
dplyr::select(-Type) | ||
``` | ||
|
||
|
||
```{r bds-data_dict} | ||
# Pull list of measures from data dictionary (primary key and filters for | ||
# only public-safe/in-use measures) | ||
# NOTE: Children_away changed to Children_Away to match BDS | ||
data_dict <- readxl::read_xlsx( | ||
path = paste0("01_data/02_prod/LAIT Data Dictionary.xlsx"), | ||
sheet = "Data_prod" | ||
) |> | ||
dplyr::mutate(Measure_short = trimws(Measure_short)) |> | ||
dplyr::filter(!grepl("DISCONTINUE", Table_status)) |> | ||
pull_uniques("Measure_short") | ||
# Filter BDS for only measures in the data dict | ||
bds_long_public <- bds_long_la |> | ||
dplyr::filter(`Short Desc` %in% data_dict) | ||
``` | ||
|
||
|
||
```{r bds-save} | ||
# Write out parquet version | ||
arrow::write_dataset( | ||
bds_long_public, | ||
here::here("01_data/02_prod/"), | ||
format = "parquet", | ||
basename_template = "bds_long_{i}.parquet" | ||
) | ||
# Write .csv version (for public use) | ||
write.csv( | ||
bds_long_public, | ||
here::here("01_data/02_prod/bds_long.csv"), | ||
row.names = FALSE | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.