Skip to content

Commit

Permalink
Sort variables with issues hbrescode (HB2018), datazone and hscp (
Browse files Browse the repository at this point in the history
#746)

* rename `hscp` to `hscp2018`

* rename `spd` as `slf_pc_lookup`

* Add `datazone2011` to coalesce code

* Rename `datazone` to `datazone2011`

* include `datazone2011_old` in selections

* Update R/fill_geographies.R

---------

Co-authored-by: James McMahon <[email protected]>
  • Loading branch information
Jennit07 and Moohan authored Jul 17, 2023
1 parent 018dced commit eae8750
Showing 1 changed file with 6 additions and 5 deletions.
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 @@ make_gpprac_lookup <- function(data) {
}

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_postcode_geogs <- function(data) {
) %>%
# Fill geographies
dplyr::left_join(
spd,
slf_pc_lookup,
by = "postcode",
suffix = c("_old", "")
) %>%
Expand All @@ -117,10 +117,11 @@ fill_postcode_geogs <- function(data) {
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"))

return(filled_postcodes)
}
Expand Down

0 comments on commit eae8750

Please sign in to comment.