Given a character vector 'vec', return an equal-length character vector of unique one-letter initials. The first letter of each string will be used, except when this results in duplicates; unique letters will be arbitrarily assigned in alphabetical order in the case of duplicates.
get_short_flags(vec)
A character vector, assumed to start with alphabetical characters
A character vector with the same length as vec
giving unique
one-letter initials
# Simple example where initials are as expected: 'a', 'b', 'c'
fruits <- c("apple", "banana", "cherry")
initials <- slurmjobs:::get_short_flags(fruits)
print(fruits)
#> [1] "apple" "banana" "cherry"
# Example with duplicates with some arbitrary initials: 'c', 'a', 'b', 'd'
fruits <- c("coconut", "cherry", "banana", "berry")
initials <- slurmjobs:::get_short_flags(fruits)
print(fruits)
#> [1] "coconut" "cherry" "banana" "berry"