| asShortNa | R Documentation |
This function aims to convert all entries from a character vector into the shortest possible upper-case code-names.
asShortNa(txt, silent = FALSE, debug = FALSE, callFrom = NULL)
txt |
(character or matrix of text) main input, text to be truncated |
silent |
(logical) suppress messages |
debug |
(logical) display additional messages for debugging |
callFrom |
(character) allow easier tracking of messages produced |
For vecors with equal or less than 26 entries this will result in single-letter 'code-names', for longer 2 letters will have to get used (tmax 676 combinations). When all entries start with different letters, the starting letter(s) of each entry will be used, otherwise (conflicting cases with same startoing letters) other letters from the end of the alphabet will be used. Duplicated text-entries will get the same abbreviation 'code-name'.
Note, all resultant text will be upper case, thus no distinction of initial lower- or upper-case letters can be made.
The function returns a character vector with shortened text (and initial text as names)
The function returns a character vector with shortened text (and initial text as names)
truncateVect , substr
txt1 <- c("BB", "CC", "GHJ", "C3", "C3", "C3H", "cdf")
txt2 <- c("BB", "CC", "GHJ", paste0("C",1:26))
asShortNa(txt1[1:3]) # like substr()
asShortNa(txt1)
asShortNa(txt2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.