This function renames duplicate entries in a list by adding an incrementing value to each duplicate while leaving unique elements unchanged.

renameDuplicateNames(input_list, order_indices = NULL)

Arguments

input_list

A vector or list containing elements to be renamed.

Value

A vector with duplicate entries renamed by adding incrementing values, while unique elements remain unchanged.

Examples

original_list <- c("a", "b", "a", "b", "c", "d", "a")
new_list <- renameDuplicateNames(original_list)
print(new_list)
#> [1] "a_1" "b_1" "a_2" "b_2" "c"   "d"   "a_3"

# Output: "a_1" "b_1" "a_2" "b_2" "c" "d" "a_3"