Type: | Package |
Title: | Readable String Abbreviation |
Version: | 0.1 |
Date: | 2021-12-12 |
Description: | Strings are abbreviated to at least "minlength" characters, such that they remain unique (if they were). The abbreviations should be recognisable. |
URL: | https://github.com/sigbertklinke/abbreviate (development version) |
RoxygenNote: | 7.1.1 |
License: | GPL-3 |
Encoding: | UTF-8 |
Suggests: | testthat (≥ 3.0.0) |
Config/testthat/edition: | 3 |
NeedsCompilation: | no |
Packaged: | 2021-12-12 14:35:02 UTC; sk |
Author: | Sigbert Klinke [aut, cre] |
Maintainer: | Sigbert Klinke <sigbert@hu-berlin.de> |
Repository: | CRAN |
Date/Publication: | 2021-12-14 08:40:04 UTC |
abbreviate_text
Description
Shorten strings to at least minlength
characters so that they remain unique (if they were).
Duplicate strings or NA
s 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: |
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)