abbreviate_text {abbreviate}R Documentation

abbreviate_text

Description

Shorten strings to at least minlength characters so that they remain unique (if they were). Duplicate strings or NAs are allowed. Note that different orders in the string may result in different abbreviations.

Usage

abbreviate_text(txt, minlength = 3, alnum = TRUE)

Arguments

txt

character: vector of strings to abbreviate

minlength

integer: the minimum length of the abbreviations

alnum

logical: should strings be reduced to alpha-numeric characters before abbreviation (default: TRUE)

Value

abbreviated strings

See Also

base::abbreviate or package uniqtag

Examples

# unique with first letters is possible
txt <- c("euclidean", "maximum", "manhattan", "canberra", "minimum")
abbreviate_text(txt, 3)
# if identical strings used then same abbreviation
txt <- c("euclidean", "maximum", "manhattan", "manhattan", "canberra", "minimum")
abbreviate_text(txt, 3)
# warnings that identical strings and identical abbreviations used
txt <- c("euclidean", "maximum", "manhattan", NA, "canberra", "minimum", "abc", "abc")
abbreviate_text(txt, 3)
# unique abbreviations
txt <- c("ward.D", "ward.D2", "single", "complete", "average", "mcquitty", "median", "centroid")
abbreviate_text(txt, 3)
# unique abbreviations, but not really intuitive
abbreviate_text(txt, 0)

[Package abbreviate version 0.1 Index]