fmt_school_name_short: Shorten a column or character vector of school names

View source: R/functions.R

fmt_school_name_shortR Documentation

Shorten a column or character vector of school names

Description

Standard grade range names are replaced with corresponding abbreviations ("E","EM","M","H","MH", and "P"). For example, "High" (appearing at the end of a string), "High school" or "High School" is replaced by HS (or H if suffix is NULL). String or column values are also passed to stringr::str_squish() and stringr::str_trim() to avoid issues with pattern matching failing due to trailing spaces or double-spaces.

Usage

fmt_school_name_short(
  data,
  .col = "school_name",
  .col_short = NULL,
  suffix = "S",
  extra_pattern = c(`All Baltimore City Public Schools` = "All City schools", Academy =
    "Acad.", Preparatory = "Prep.", Square = "Sq.", `^Commodore` = "Com.", `, The$` = "")
)

vec_fmt_school_name_short(
  string,
  suffix = "S",
  extra_pattern = c(`All Baltimore City Public Schools` = "All City schools", Academy =
    "Acad.", Preparatory = "Prep.", Square = "Sq.", `^Commodore` = "Com.", `, The$` = "")
)

Arguments

data

Data frame with column name matching .col that contains school names to shorten.

.col

Column name to shorten. Values are replaced if .col_short is supplied.

.col_short

Column name for new column with short names.

suffix

Suffix to append to standard abbreviations. Defaults to "S"

extra_pattern

Additional replacements added to standard pattern and passed to stringr::str_replace_all()

string

Character vector of school names to shorten.


elipousson/bcps documentation built on Feb. 7, 2024, 2:58 a.m.