EVOLUTION-MANAGER
Edit File: vec_names.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: Get or set the names of a vector</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 vec_names {vctrs}"><tr><td>vec_names {vctrs}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get or set the names of a vector</h2> <h3>Description</h3> <p>These functions work like <code><a href="../../rlang/html/names2.html">rlang::names2()</a></code>, <code><a href="../../base/html/names.html">names()</a></code> and <code><a href="../../base/html/names.html">names<-()</a></code>, except that they return or modify the the rowwise names of the vector. These are: </p> <ul> <li><p> The usual <code>names()</code> for atomic vectors and lists </p> </li> <li><p> The row names for data frames and matrices </p> </li> <li><p> The names of the first dimension for arrays Rowwise names are size consistent: the length of the names always equals <code><a href="vec_size.html">vec_size()</a></code>. </p> </li></ul> <p><code>vec_names2()</code> returns the repaired names from a vector, even if it is unnamed. See <code><a href="vec_as_names.html">vec_as_names()</a></code> for details on name repair. </p> <p><code>vec_names()</code> is a bare-bones version that returns <code>NULL</code> if the vector is unnamed. </p> <p><code>vec_set_names()</code> sets the names or removes them. </p> <h3>Usage</h3> <pre> vec_names2( x, ..., repair = c("minimal", "unique", "universal", "check_unique", "unique_quiet", "universal_quiet"), quiet = FALSE ) vec_names(x) vec_set_names(x, names) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector with names</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>These dots are for future extensions and must be empty.</p> </td></tr> <tr valign="top"><td><code>repair</code></td> <td> <p>Either a string or a function. If a string, it must be one of <code>"check_unique"</code>, <code>"minimal"</code>, <code>"unique"</code>, <code>"universal"</code>, <code>"unique_quiet"</code>, or <code>"universal_quiet"</code>. If a function, it is invoked with a vector of minimal names and must return minimal names, otherwise an error is thrown. </p> <ul> <li><p> Minimal names are never <code>NULL</code> or <code>NA</code>. When an element doesn't have a name, its minimal name is an empty string. </p> </li> <li><p> Unique names are unique. A suffix is appended to duplicate names to make them unique. </p> </li> <li><p> Universal names are unique and syntactic, meaning that you can safely use the names as variables without causing a syntax error. </p> </li></ul> <p>The <code>"check_unique"</code> option doesn't perform any name repair. Instead, an error is raised if the names don't suit the <code>"unique"</code> criteria. </p> <p>The options <code>"unique_quiet"</code> and <code>"universal_quiet"</code> are here to help the user who calls this function indirectly, via another function which exposes <code>repair</code> but not <code>quiet</code>. Specifying <code>repair = "unique_quiet"</code> is like specifying <code style="white-space: pre;">repair = "unique", quiet = TRUE</code>. When the <code>"*_quiet"</code> options are used, any setting of <code>quiet</code> is silently overridden.</p> </td></tr> <tr valign="top"><td><code>quiet</code></td> <td> <p>By default, the user is informed of any renaming caused by repairing the names. This only concerns unique and universal repairing. Set <code>quiet</code> to <code>TRUE</code> to silence the messages. </p> <p>Users can silence the name repair messages by setting the <code>"rlib_name_repair_verbosity"</code> global option to <code>"quiet"</code>.</p> </td></tr> <tr valign="top"><td><code>names</code></td> <td> <p>A character vector, or <code>NULL</code>.</p> </td></tr> </table> <h3>Value</h3> <p><code>vec_names2()</code> returns the names of <code>x</code>, repaired. <code>vec_names()</code> returns the names of <code>x</code> or <code>NULL</code> if unnamed. <code>vec_set_names()</code> returns <code>x</code> with names updated. </p> <h3>Examples</h3> <pre> vec_names2(1:3) vec_names2(1:3, repair = "unique") vec_names2(c(a = 1, b = 2)) # `vec_names()` consistently returns the rowwise names of data frames and arrays: vec_names(data.frame(a = 1, b = 2)) names(data.frame(a = 1, b = 2)) vec_names(mtcars) names(mtcars) vec_names(Titanic) names(Titanic) vec_set_names(1:3, letters[1:3]) vec_set_names(data.frame(a = 1:3), letters[1:3]) </pre> <hr /><div style="text-align: center;">[Package <em>vctrs</em> version 0.5.0 <a href="00Index.html">Index</a>]</div> </body></html>