string_std: String standardization prior to matching

View source: R/string_std.R

string_stdR Documentation

String standardization prior to matching

Description

Standardizes strings prior to performing a match, using the following transformations:

  1. standardize case (base::tolower)

  2. remove sequences of non-alphanumeric characters at start or end of string

  3. replace remaining sequences of non-alphanumeric characters with "_"

  4. remove diacritics (stringi::stri_trans_general)

  5. (optional) convert roman numerals (I, II, ..., XLIX) to arabic (1, 2, ..., 49)

Usage

string_std(x, convert_roman = FALSE)

Arguments

x

a string

convert_roman

logical indiciating whether to convert roman numerals (I, II, ..., XLIX) to arabic (1, 2, ..., 49)

Value

The standardized version of x

See Also

string_standardization

Examples

string_std("United STATES")
string_std("R\u00e9publique  d\u00e9mocratique du  Congo")

# convert roman numerals to arabic
string_std("Mungindu-II (Sud)")
string_std("Mungindu-II (Sud)", convert_roman = TRUE)

# note the conversion only works if the numeral is separated from other
# alphanumeric characters by punctuation or space characters
string_std("MunginduII", convert_roman = TRUE) # roman numeral not recognized


epicentre-msf/hmatch documentation built on Nov. 15, 2023, 1:47 a.m.