make_unique: Make Values Unique

View source: R/make_unique.R

make_uniqueR Documentation

Make Values Unique

Description

Append numbers to duplicate values to ensure all are unique

Usage

make_unique(
  x,
  sep = " ",
  wrap_in_brackets = TRUE,
  warn_about_type_conversion = TRUE
)

Arguments

x

vector to de-duplicate

sep

string separating (string)

wrap_in_brackets

should the number indicating order of duplicated elements be wrapped in round brackets? (flag)

warn_about_type_conversion

should the function warn user if input type is converted to 'character' in output (flag)

Details

Differs from 'make.unique' in base R by starting suffixes at 1 and allowing users to customize suffix format.

Value

x but duplicated values are de-duplicated by adding a number corresponding to the order in which duplicates appear

Examples

make_unique(c('bob', 'billy', 'bob', 'bob'))

makeunique documentation built on Oct. 14, 2022, 1:08 a.m.