Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sort variables with issues hbrescode (HB2018), datazone and hscp #746

Merged
merged 8 commits into from
Jul 17, 2023
11 changes: 6 additions & 5 deletions R/fill_geographies.R
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
}

fill_postcode_geogs <- function(data) {
spd <- read_file(get_slf_postcode_path())
slf_pc_lookup <- read_file(get_slf_postcode_path())

filled_postcodes <- dplyr::left_join(
data,
Expand All @@ -102,7 +102,7 @@
) %>%
# Fill geographies
dplyr::left_join(
spd,
slf_pc_lookup,
by = "postcode",
suffix = c("_old", "")
) %>%
Expand All @@ -117,10 +117,11 @@
cascade_geographies() %>%
dplyr::mutate(
hbrescode = dplyr::coalesce(.data$hb2018, .data$hbrescode),
hscp = dplyr::coalesce(.data$hscp2018, .data$hscp),
lca = dplyr::coalesce(.data$lca, .data$lca_old)
hscp2018 = dplyr::coalesce(.data$hscp2018, .data$hscp),
lca = dplyr::coalesce(.data$lca, .data$lca_old),
datazone2011 = dplyr::coalesce(.data$datazone2011, .data$datazone2011_old)
) %>%
dplyr::select(!c("hb2018", "hscp2018", "lca_old", "most_recent_postcode"))
dplyr::select(!c("hb2018", "hscp", "lca_old", "datazone2011_old", "most_recent_postcode"))

Check warning on line 124 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=124,col=81,[line_length_linter] Lines should not be more than 80 characters.

return(filled_postcodes)
}
Expand Down Expand Up @@ -161,13 +162,13 @@
#'
#' @return data with matched HSCP and LCA codes
cascade_geographies <- function(data) {
# TODO rework this function into a series of smaller functions which operate on vectors

Check warning on line 165 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=165,col=81,[line_length_linter] Lines should not be more than 80 characters.
# e.g. cascade_hscp_lca <- function(hscp, lca) {...}
# Would take HSCP and populate any missing LCA using it
data <- data %>%
dplyr::mutate(
# If we can, 'cascade' the geographies upwards
# i.e. if they have an LCA use this to fill in HSCP2018 and so on for hbrescode

Check warning on line 171 in R/fill_geographies.R

View workflow job for this annotation

GitHub Actions / lint-changed-files

file=R/fill_geographies.R,line=171,col=81,[line_length_linter] Lines should not be more than 80 characters.
# Codes are correct as at August 2018
lca = dplyr::case_when(
!is_missing(lca) ~ lca,
Expand Down
Loading