Title: Make Character Strings Unique
Version: 1.0.0
Description: Make all elements of a character vector unique. Differs from 'make.unique' by starting at 1 and allowing users to customise suffix format.
License: MIT + file LICENSE
Suggests: covr, knitr, rmarkdown, testthat (≥ 3.0.0)
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.0
URL: https://github.com/selkamand/makeunique
BugReports: https://github.com/selkamand/makeunique/issues
NeedsCompilation: no
Packaged: 2022-10-12 09:34:07 UTC; User
Author: Sam El-Kamand ORCID iD [aut, cre, cph]
Maintainer: Sam El-Kamand <sam.elkamand@gmail.com>
Repository: CRAN
Date/Publication: 2022-10-13 17:30:01 UTC

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'))