str_normal {campfin}R Documentation

Normalize a character string

Description

The generic normalization that underpins functions like normal_city() and normal_address(). This function simply chains together three ⁠stringr::str_*()⁠ functions:

  1. Convert to uppercase.

  2. Replace punctuation with whitespaces.

  3. Trim and squish excess whitespace.

Usage

str_normal(x, case = TRUE, punct = "", quote = TRUE, squish = TRUE)

Arguments

x

A character string to normalize.

case

logical; whether stringr::str_to_upper() should be called.

punct

character; A character string to replace most punctuation with.

quote

logical; whether stringr::str_replace_all() should be called on double quotes.

squish

logical; whether stringr::str_squish() should be called.

Value

A normalized vector of the same length.

See Also

Other geographic normalization functions: abbrev_full(), abbrev_state(), check_city(), expand_abbrev(), expand_state(), fetch_city(), normal_address(), normal_city(), normal_state(), normal_zip()

Examples

str_normal("   TestING 123   example_test.String   ")

[Package campfin version 1.0.11 Index]