Strings are abbreviated to at least "minlength" characters, such that they remain unique (if they were). The abbreviations should be recognisable.
install.packages("abbreviate")
Note that from github you install the current development version.
library("devtools")
install_github("sigbertklinke/abbreviate")
# 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)
#
# 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)
#
# factor variable
abbreviate_text(unique(iris[,5]))
abbreviate_text(iris[,5])
- 2021-12-12 version 0.1