Description Usage Arguments Value See Also Examples
View source: R/abbreviate_text.R
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.
1 | abbreviate_text(txt, minlength = 3, alnum = TRUE)
|
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: |
abbreviated strings
base::abbreviate or package uniqtag
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | # 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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.