asShortNa: Convert Character Vector Into Very Short Upper-Case...

View source: R/asShortNa.R

asShortNaR Documentation

Convert Character Vector Into Very Short Upper-Case 'Code-Names'

Description

This function aims to convert all entries from a character vector into the shortest possible upper-case code-names.

Usage

asShortNa(txt, silent = FALSE, debug = FALSE, callFrom = NULL)

Arguments

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

Details

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)

Value

The function returns a character vector with shortened text (and initial text as names)

See Also

truncateVect , substr

Examples

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)


wrMisc documentation built on Nov. 18, 2026, 5:06 p.m.