EVOLUTION-MANAGER
Edit File: is_named.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: Is object named?</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 is_named {rlang}"><tr><td>is_named {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Is object named?</h2> <h3>Description</h3> <ul> <li> <p><code>is_named()</code> is a scalar predicate that checks that <code>x</code> has a <code>names</code> attribute and that none of the names are missing or empty (<code>NA</code> or <code>""</code>). </p> </li> <li> <p><code>is_named2()</code> is like <code>is_named()</code> but always returns <code>TRUE</code> for empty vectors, even those that don't have a <code>names</code> attribute. In other words, it tests for the property that each element of a vector is named. <code>is_named2()</code> composes well with <code><a href="names2.html">names2()</a></code> whereas <code>is_named()</code> composes with <code>names()</code>. </p> </li> <li> <p><code>have_name()</code> is a vectorised variant. </p> </li></ul> <h3>Usage</h3> <pre> is_named(x) is_named2(x) have_name(x) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x</code></td> <td> <p>A vector to test.</p> </td></tr> </table> <h3>Details</h3> <p><code>is_named()</code> always returns <code>TRUE</code> for empty vectors because </p> <h3>Value</h3> <p><code>is_named()</code> and <code>is_named2()</code> are scalar predicates that return <code>TRUE</code> or <code>FALSE</code>. <code>have_name()</code> is vectorised and returns a logical vector as long as the input. </p> <h3>Examples</h3> <pre> # is_named() is a scalar predicate about the whole vector of names: is_named(c(a = 1, b = 2)) is_named(c(a = 1, 2)) # Unlike is_named2(), is_named() returns `FALSE` for empty vectors # that don't have a `names` attribute. is_named(list()) is_named2(list()) # have_name() is a vectorised predicate have_name(c(a = 1, b = 2)) have_name(c(a = 1, 2)) # Empty and missing names are treated as invalid: invalid <- set_names(letters[1:5]) names(invalid)[1] <- "" names(invalid)[3] <- NA is_named(invalid) have_name(invalid) # A data frame normally has valid, unique names is_named(mtcars) have_name(mtcars) # A matrix usually doesn't because the names are stored in a # different attribute mat <- matrix(1:4, 2) colnames(mat) <- c("a", "b") is_named(mat) names(mat) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>