-
Notifications
You must be signed in to change notification settings - Fork 306
/
make.unique.Rd
49 lines (44 loc) · 1.43 KB
/
make.unique.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
% File src/library/base/man/make.unique.Rd
% Part of the R package, http://www.R-project.org
% Copyright 1995-2007 R Core Development Team
% Distributed under GPL 2 or later
\name{make.unique}
\alias{make.unique}
\title{Make Character Strings Unique}
\description{
Makes the elements of a character vector unique by
appending sequence numbers to duplicates.
}
\usage{
make.unique(names, sep = ".")
}
\arguments{
\item{names}{a character vector}
\item{sep}{a character string used to separate a duplicate name from
its sequence number.}
}
\value{
A character vector of same length as \code{names} with duplicates changed.
}
\details{
The algorithm used by \code{make.unique} has the property that
\code{make.unique(c(A, B)) == make.unique(c(make.unique(A), B))}.
In other words, you can append one string at a time to a vector,
making it unique each time, and get the same result as applying
\code{make.unique} to all of the strings at once.
If character vector \code{A} is already unique, then
\code{make.unique(c(A, B))} preserves \code{A}.
}
\author{Thomas P Minka}
\seealso{
\code{\link{make.names}}
}
\examples{
make.unique(c("a", "a", "a"))
make.unique(c(make.unique(c("a", "a")), "a"))
make.unique(c("a", "a", "a.2", "a"))
make.unique(c(make.unique(c("a", "a")), "a.2", "a"))
rbind(data.frame(x=1), data.frame(x=2), data.frame(x=3))
rbind(rbind(data.frame(x=1), data.frame(x=2)), data.frame(x=3))
}
\keyword{character}