Shorten a vector of names by removing common substrings, applying custom replacements, replacing "__" with "", then "" with ".", removing duplicates, and truncating to a maximum length.

shorten_names(names, max_length = 20, custom_replacements = NULL)

Arguments

names

A vector of names to shorten.

max_length

The maximum length of the shortened names. Defaults to 20.

custom_replacements

A list of custom replacements to apply. Defaults to NULL.

Value

A vector of shortened names.

Examples

names <- c("npsy_BDI_Total", "npsy_BSI.18_TotalRaw", "npsy_CVLTShortDelayFreeRecall_Raw")
shortened_names <- shorten_names(names)
print(shortened_names)
#> [1] "bdi.tot"          "bsi.18.tot"       "cvltshortdelrcl."