tidy_string: Truncate a string to a standard size

Description Usage Arguments Details Examples

Description

It's often useful in doing partial string comparisons (eg, for comparing street addresses) to remove non-standard characters and reduce the length.

Usage

1
2
tidy_string(string, length = -1, pattern = "[^A-Za-z0-9]",
  lowercase = TRUE)

Arguments

string

character vector of strings to truncate

length

how long (at most) the resulting strings should be. -1 (default) to not truncate.

pattern

regex pattern for characters that should be removed.

Details

By default, only alpha-numeric characters are retained

Examples

1
2
3
address1 <- "123 N Washington way"
address2 <- "123 N. Washington"
identical(str_truncate(address1, 8), str_truncate(address2, 8))

tarakc02/preprocessr documentation built on May 31, 2019, 3:55 a.m.