make.unique
Make Character Strings Unique
Description
Makes unique all elements of a character vector by
appending sequence numbers to duplicates.
Usage
make.unique(names, sep = ".")
Arguments
names |
a vector of character strings.
|
sep |
a character string used as a separator between a duplicate
string and the appended sequence number.
The default is ".".
|
Details
If character vector A is already unique, then make.unique(c(A, B))
preserves A.
When you create unique row names for large data frames, TIBCO Enterprise Runtime for R allocates
a large amount of memory. The memory is recovered if the process is
interrupted.
Value
returns a character vector with the same length as names
and containing unique strings.
See Also
Examples
make.unique(c("a", "a", "a", "a"))
# "a" "a.1" "a.2" "a.3"
make.unique(c("a", "a", "a", "a.1"))
# "a" "a.2" "a.3" "a.1"
make.unique(c(make.unique(c("a", "a", "a")), "a"))
# "a" "a.1" "a.2" "a.3"
# unique vector A is not changed
A <- c("a","b","c")
B <- c("b","c","d")
make.unique(c(A,B))
# "a" "b" "c" "b.1" "c.1" "d"