EVOLUTION-MANAGER
Edit File: names2.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 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 names2 {rlang}"><tr><td>names2 {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Get names of a vector</h2> <h3>Description</h3> <p><code>names2()</code> always returns a character vector, even when an object does not have a <code>names</code> attribute. In this case, it returns a vector of empty names <code>""</code>. It also standardises missing names to <code>""</code>. </p> <p>The replacement variant <code style="white-space: pre;">names2<-</code> never adds <code>NA</code> names and instead fills unnamed vectors with <code>""</code>. </p> <h3>Usage</h3> <pre> names2(x) names2(x) <- value </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector.</p> </td></tr> <tr valign="top"><td><code>value</code></td> <td> <p>New names.</p> </td></tr> </table> <h3>Examples</h3> <pre> names2(letters) # It also takes care of standardising missing names: x <- set_names(1:3, c("a", NA, "b")) names2(x) # Replacing names with the base `names<-` function may introduce # `NA` values when the vector is unnamed: x <- 1:3 names(x)[1:2] <- "foo" names(x) # Use the `names2<-` variant to avoid this x <- 1:3 names2(x)[1:2] <- "foo" names(x) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>