powered by
Fix duplicated values in a character vector, useful in column names and some ID structures that requires unique identifiers. If any duplicated string is found in the vector, a numeric index will be added after the these strings.
strUniquefy(x, sep_b = "_", sep_a = "", mark_first = TRUE)
returns a character vector
character vector
string, separator before the number index
string, separator after the number index
bool, if duplicated values are found, do you want to add the numeric index starting from the first copy? `FALSE` means starting from the second copy.
The input can also be a numeric vector, but the return will always be character.
strUniquefy(c(1,1,1,2,3)) strUniquefy(c(1,1,1,2,3), mark_first = FALSE) strUniquefy(c(1,1,1,2,3), sep_b = "(", sep_a = ")") strUniquefy(c("a","b","c","a","d","b"))
Run the code above in your browser using DataLab