EVOLUTION-MANAGER
Edit File: vector-construction.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: Create vectors</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 vector-construction {rlang}"><tr><td>vector-construction {rlang}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create vectors</h2> <h3>Description</h3> <p><a href="https://lifecycle.r-lib.org/articles/stages.html#questioning"><img src="../help/figures/lifecycle-questioning.svg" alt='[Questioning]' /></a> </p> <p>The atomic vector constructors are equivalent to <code><a href="../../base/html/c.html">c()</a></code> but: </p> <ul> <li><p> They allow you to be more explicit about the output type. Implicit coercions (e.g. from integer to logical) follow the rules described in <a href="vector-coercion.html">vector-coercion</a>. </p> </li> <li><p> They use <a href="dyn-dots.html">dynamic dots</a>. </p> </li></ul> <h3>Usage</h3> <pre> lgl(...) int(...) dbl(...) cpl(...) chr(...) bytes(...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>...</code></td> <td> <p>Components of the new vector. Bare lists and explicitly spliced lists are spliced.</p> </td></tr> </table> <h3>Life cycle</h3> <ul> <li><p> All the abbreviated constructors such as <code>lgl()</code> will probably be moved to the vctrs package at some point. This is why they are marked as questioning. </p> </li> <li><p> Automatic splicing is soft-deprecated and will trigger a warning in a future version. Please splice explicitly with <code style="white-space: pre;">!!!</code>. </p> </li></ul> <h3>Examples</h3> <pre> # These constructors are like a typed version of c(): c(TRUE, FALSE) lgl(TRUE, FALSE) # They follow a restricted set of coercion rules: int(TRUE, FALSE, 20) # Lists can be spliced: dbl(10, !!! list(1, 2L), TRUE) # They splice names a bit differently than c(). The latter # automatically composes inner and outer names: c(a = c(A = 10), b = c(B = 20, C = 30)) # On the other hand, rlang's constructors use the inner names and issue a # warning to inform the user that the outer names are ignored: dbl(a = c(A = 10), b = c(B = 20, C = 30)) dbl(a = c(1, 2)) # As an exception, it is allowed to provide an outer name when the # inner vector is an unnamed scalar atomic: dbl(a = 1) # Spliced lists behave the same way: dbl(!!! list(a = 1)) dbl(!!! list(a = c(A = 1))) # bytes() accepts integerish inputs bytes(1:10) bytes(0x01, 0xff, c(0x03, 0x05), list(10, 20, 30L)) </pre> <hr /><div style="text-align: center;">[Package <em>rlang</em> version 1.0.6 <a href="00Index.html">Index</a>]</div> </body></html>