This helper function generates a set of unique labels given unique IDs and not necessarily unique names.

h_unique_labels(ids, nms = NULL)

Arguments

ids

(character or NULL)
unique IDs.

nms

(character or NULL)
not necessarily unique names if provided.

Value

Character vector where empty names are replaced by the IDs and non-unique names are made unique by appending the IDs in parentheses.

Examples

h_unique_labels(c("1", "2", "3"), c("A", "B", "A"))
#> [1] "A (1)" "B"     "A (3)"
h_unique_labels(NULL)
#> NULL
h_unique_labels(c("1", "2", "3"))
#> [1] "1" "2" "3"