EVOLUTION-MANAGER
Edit File: make.unique.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Make Character Strings Unique</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for make.unique {base}"><tr><td>make.unique {base}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Make Character Strings Unique</h2> <h3>Description</h3> <p>Makes the elements of a character vector unique by appending sequence numbers to duplicates. </p> <h3>Usage</h3> <pre> make.unique(names, sep = ".") </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>names</code></td> <td> <p>a character vector</p> </td></tr> <tr valign="top"><td><code>sep</code></td> <td> <p>a character string used to separate a duplicate name from its sequence number.</p> </td></tr> </table> <h3>Details</h3> <p>The algorithm used by <code>make.unique</code> has the property that <code>make.unique(c(A, B)) == make.unique(c(make.unique(A), B))</code>. </p> <p>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</code> to all of the strings at once. </p> <p>If character vector <code>A</code> is already unique, then <code>make.unique(c(A, B))</code> preserves <code>A</code>. </p> <h3>Value</h3> <p>A character vector of same length as <code>names</code> with duplicates changed, in the current locale's encoding. </p> <h3>Author(s)</h3> <p>Thomas P. Minka</p> <h3>See Also</h3> <p><code><a href="make.names.html">make.names</a></code> </p> <h3>Examples</h3> <pre> 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")) ## Now show a bit where this is used : trace(make.unique) ## Applied in data.frame() constructions: (d1 <- data.frame(x = 1, x = 2, x = 3)) # direct d2 <- data.frame(data.frame(x = 1, x = 2), x = 3) # pairwise stopifnot(identical(d1, d2), colnames(d1) == c("x", "x.1", "x.2")) untrace(make.unique) </pre> <hr /><div style="text-align: center;">[Package <em>base</em> version 3.6.0 <a href="00Index.html">Index</a>]</div> </body></html>