Creates abbreviations of character strings such that they remain distinguishable within the input vector.
Usage
strAbbr(x, minchar = 1, method = c("left", "fix"))Details
The function ensures that abbreviations are unique (within the given
vector) while respecting the minimum length minchar.
For method = "left", each string is shortened individually to the
shortest prefix that distinguishes it from all others.
For method = "fix", a single prefix length is chosen such that all
strings are distinguishable.
Unicode-aware substring operations are performed using the stringi package.
See also
stringi::stri_sub(),
stringi::stri_length()
string-overview for an overview of all string utilities in pharos.
Examples
x <- c("apple", "apricot", "banana")
# individual minimal abbreviations
strAbbr(x, method = "left")
#> [1] "app" "apr" "b"
# fixed length abbreviations
strAbbr(x, method = "fix")
#> [1] "app" "apr" "ban"
