Skip to contents

# Make unique variable names

Source: `R/update-factor-ext.R`
`unique_names.Rd`

Helper function to create new variable names that are unique given a set of existing names (in a data set, for example). If a variable name already exists, a number will be appended.

## Usage

    unique_names(new, existing = character())

## Arguments

new

  a vector of proposed new variable names

existing

  a vector of existing variable names

## Value

a vector of unique new variable names

## Examples

    unique_names(c("var_x", "var_y", "var_x"), c("var_x", "var_z"))
    #> [1] "var_x_1" "var_y"   "var_x_2"