Skip to contents

Returns a name that is not yet contained in a vector myNames of existing names.

Usage

hsSafeName(myName, myNames)

Arguments

myName

desired name.

myNames

vector of existing names.

Value

If myName is not contained in myNames it is returned. Otherwise myName is modified to myName_01, myName_02, ... until a non-existing name is found that is then returned.

Examples

existing <- c("a", "b")
myName <- hsSafeName("c", existing)
myName                               # "c"
#> [1] "c"
myName <- hsSafeName("a", existing)
myName                               # "a_1"
#> [1] "a_1"
hsSafeName("a", c(existing, myName)) # "a_2"
#> [1] "a_2"