hsSafeName: Non-existing desired name

View source: R/main.R

hsSafeNameR Documentation

Non-existing desired name

Description

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"
myName <- hsSafeName("a", existing)
myName                               # "a_1"
hsSafeName("a", c(existing, myName)) # "a_2"
  

KWB-R/kwb.utils documentation built on April 1, 2024, 7:12 a.m.