R/col_formatter.R

Defines functions col_formatter

Documented in col_formatter

#' Function to remove extraneous characters from strings
#'
#' @param df a tidycensus dataframe
#'
#' @return a tidycensus dataframe with extraneous characters removed
#' @export
#'
#' @examples
col_formatter <- function(df){

  df %>%
    # filter(!!sym(col_name) != "White alone") %>%
    dplyr::mutate(dplyr::across(where(is.character), ~ gsub(":", "", .x)),
                  dplyr::across(where(is.character), ~ gsub(" alone", "", .x)),
                  dplyr::across(where(is.character), ~ gsub(" or ", "/", .x)))
}
dpowerstp/acsprocess documentation built on Sept. 4, 2022, 10:18 a.m.