unduplicate: unduplicate elements in a vector

Description Usage Arguments Value Author(s) See Also Examples

Description

Similar to make.unique, ensure that all elements in x are unique. Note that duplicate can mean any number of repetitions, not just 2. This differs from make.unique in that all instances of a duplicated element are tagged with a numeric suffix, as opposed to the 2:n elements that get tagged by make.unique. see examples

Usage

1
unduplicate(x, sep = ".")

Arguments

x

a character vector

sep

the seperator between <original><sep><integer>

Value

a character vector, length(x), where all elements are unique

Author(s)

Mark Cowley, 2012-05-02

See Also

make.unique

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
x <- c("a","a","a","b","b")
unduplicate(x)
# [1] "a.1" "a.2" "a.3" "b.1" "b.2"
# compared to make.unique where the first 'a' and 'b' are unchanged.
make.unique(x)
# [1] "a"   "a.1" "a.2" "b"   "b.1"
unduplicate(letters[1:6])
# [1] "a" "b" "c" "d" "e" "f"
unduplicate(c(x,NA, NA, NA))
# [1] "a.1" "a.2" "a.3" "b.1" "b.2" NA    NA    NA   

drmjc/mjcbase documentation built on May 15, 2019, 2:27 p.m.