\Header{make.unique}{Make Character Strings Unique}
\keyword{character}{make.unique}
\begin{Description}\relax
Makes the elements of a character vector unique by
appending sequence numbers to duplicates.
\end{Description}
\begin{Usage}
\begin{verbatim}
make.unique(names, sep = ".")
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{names}] a character vector
\item[\code{sep}] a character string used to separate a duplicate name from
its sequence number.
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
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}.
\end{Details}
\begin{Value}
A character vector of same length as \code{names} with duplicates changed.
\end{Value}
\begin{Author}\relax
Thomas P Minka
\end{Author}
\begin{SeeAlso}\relax
\code{\Link{make.names}}
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
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))
\end{ExampleCode}
\end{Examples}

