standardize_string: Standardize String Formatting

View source: R/standardize.R

standardize_stringR Documentation

Standardize String Formatting

Description

standardize_string ensures that the input string (or character vector) follows a consistent structure. It coerces the input to type character; converts characters to UTF-8 encoding; replaces non-alphabetical symbols with a space; removes excess whitespace; and converts to the desired case (title, by default). It also informs the user if any characters could not be converted to UTF-8.

Usage

standardize_string(string, case_fn = stringr::str_to_title, ...)

Arguments

string

The string or character vector to standardize

case_fn

A function for converting to the desired case. Note that case_fn is simply the last transformation applied to string and may technically perform operations other than case conversion.

...

Additional parameters to pass to case_fn

Details

This function is primarily intended to standardize proper nouns (such as names of persons) into a common format; it doesn't necessarily correct the strings. For more general string standardization of this type, see the snakecase package.

Value

A character vector of the same length as string


jesse-smith/coviData documentation built on Jan. 14, 2023, 11:08 a.m.