make_unique: Make character strings unique.

Description Usage Arguments Functions See Also Examples

View source: R/uniqtag.R

Description

Apppend sequence numbers to duplicate elements to make all elements of a character vector unique.

Usage

1
2
3
4
5
6
7
make_unique(xs, sep = "-")

make_unique_duplicates(xs, sep = "-")

make_unique_all(xs, sep = "-")

make_unique_all_or_none(xs, sep = "-")

Arguments

xs

a character vector

sep

a character string used to separate a duplicate string from its sequence number

Functions

See Also

make.unique

Examples

1
2
3
4
5
6
7
8
abcb <- c("a", "b", "c", "b")
make_unique(abcb)
make_unique_duplicates(abcb)
make_unique_all(abcb)
make_unique_all_or_none(abcb)
make_unique_all_or_none(c("a", "b", "c"))
x <- make_unique(abbreviate(state.name, 3, strict = TRUE))
x[grep("-", x)]

Example output

[1] "a"   "b-1" "c"   "b-2"
[1] "a"   "b"   "c"   "b-1"
[1] "a-1" "b-1" "c-1" "b-2"
[1] "a-1" "b-1" "c-1" "b-2"
[1] "a" "b" "c"
Massachusetts   Mississippi      Missouri 
      "Mss-1"       "Mss-2"       "Mss-3" 

uniqtag documentation built on May 29, 2017, 9:11 a.m.