R/tidy_postcode.R

Defines functions tidy_postcode

Documented in tidy_postcode

#' Tidy a lazy_table postcode
#'
#' Tidy a postcode so it is ready for joining.
#'
#' @param df Database table
#' @param col Postcode column
#'
#' @examples
#'
#' @export
tidy_postcode <- function(df, col) {

  # Tide the postcode column
  df %>%
    dplyr::mutate(
      # Remove anything not a character or digit
      {{ col }} := REGEXP_REPLACE(toupper({{ col }}), "[^A-Z0-9]", "")
    )
}
nhsbsa-data-analytics/addressMatchR documentation built on June 16, 2024, 6:03 a.m.